You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For many use cases a JAX-RS applications needs to know the URI actually used by the caller. Just one example is the Location header to be returned with a 201 Created response. Unfortunately, Uri.getRequestUri() does not contain the actual URI used by the caller, but it in fact contains the base URI provided when bootstrapping Jersey. This is problematic in case where (a) bootstrapping happened using "localhost" but caller is not on the same host (so Location would contain localhost, hence resolves to the caller's machine, or (b) the server has additional aliases for external callers, so returns Location with the canonical (possible "internal") host name while the caller expects an alias - in which case the caller cannot reach the server!
IMHO this is a bug. getRequestUri() should always return the host found in the Host header, but should never return localhost.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
For many use cases a JAX-RS applications needs to know the URI actually used by the caller. Just one example is the
Location
header to be returned with a201 Created
response. Unfortunately, Uri.getRequestUri() does not contain the actual URI used by the caller, but it in fact contains the base URI provided when bootstrapping Jersey. This is problematic in case where (a) bootstrapping happened using "localhost" but caller is not on the same host (soLocation
would containlocalhost
, hence resolves to the caller's machine, or (b) the server has additional aliases for external callers, so returnsLocation
with the canonical (possible "internal") host name while the caller expects an alias - in which case the caller cannot reach the server!IMHO this is a bug. getRequestUri() should always return the host found in the
Host
header, but should never returnlocalhost
.WDYT?
Beta Was this translation helpful? Give feedback.
All reactions