Thanks man, I'd much rather NOT code it into my app. I'll take a look at
your blog and see if I can translate it to Jetty.
On Thu, Feb 6, 2014 at 2:04 PM, Joe Mocker <jmocker_at_tremorvideo.com> wrote:
> Assuming you are using Tomcat, it can do a lot of this for you, so you
> don't have to muck with workarounds like this to do the right thing.
>
> I wrote an article about this some time ago, presenting different options
> and how use them. I'd suggest you take a look at them, rather than coding
> it all into your application, which will surely break at some point in the
> future when you're changing your architecture leaving you head scratching...
>
> Anyways take a look...
>
>
> http://creechy.wordpress.com/2011/08/22/ssl-termination-load-balancers-java/
>
> --joe
>
> On Feb 6, 2014, at 11:29 AM, Robert DiFalco <robert.difalco_at_gmail.com>
> wrote:
>
> Alright, got it. For anyone else that ever needs to do this. The heroku
> router forwards requests to your server. If your client uses SSL it will be
> forwarded on to you as just HTTP. To create a proper SEE OTHER location
> with the correct scheme, you just need to do the following:
>
> String fowardedProto = headers.getHeaderString( "x-forwarded-proto" );
> String protocol = fowardedProto == null ? "http" : fowardedProto;
>
> URI seeOtherLocation = uriInfo.getAbsolutePathBuilder().scheme(
> protocol ).path( userId.toString() ).build();
>
>
>
> On Thu, Feb 6, 2014 at 11:12 AM, Robert DiFalco <robert.difalco_at_gmail.com>wrote:
>
>> Okay, I figured out how to get this from @Context HttpHeaders, what I
>> can't figure out is the simplest/cleanest way to replace HTTP with this
>> value (say HTTPS) in a path from UriInfo.getAbsolutePathBuilder. I would
>> like to do the equivalent of this:
>>
>> String fowardedProto = headers.getHeaderString( "x-forwarded-proto" );
>> String protocol = fowardedProto == null ? "http" : fowardedProto;
>>
>> URI seeOtherLocation = uriInfo.getAbsolutePathBuilder().protocol(
>> protocol ).path( userId.toString() ).build();
>>
>> But of course there is no simple "protocol" method in UriBuilder. So
>> what's the best way?
>>
>>
>>
>> On Thu, Feb 6, 2014 at 10:42 AM, Robert DiFalco <robert.difalco_at_gmail.com
>> > wrote:
>>
>>> Hi, my server sits on heroku which uses an SSL Endpoint. It looks like
>>> heroku handles the SSL itself and sends the requests on to my server as
>>> HTTP.
>>>
>>> I need to create a 303 location that knows if the request was HTTP or
>>> HTTPS. To do this I need to look at the x-forwarded-proto.
>>>
>>> How can I get this from within a REST call (for example a GET)? I need
>>> to make sure the location I give to the client for the 303 is properly
>>> specified as HTTP or HTTPS based on this.
>>>
>>> Thanks!
>>>
>>
>>
>
>