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!
>>
>
>