Details
-
Bug
-
Resolution: Not a Bug
-
Major
-
None
-
4.0.0.Final
-
None
Description
Hi, I am creating a Rest endpoint to create new objects. Basically my POST method looks like:
return Response.created(URI.create( Long.toString(book.id)) ).build();
If you check the Javadoc of the created method says:
_the URI of the new resource. If a relative URI is supplied it will be converted into an absolute URI by resolving it relative to the request URI (see
{@link UriInfo#getRequestUri})._
So if I print this value I got
System.out.println(uriInfo.getRequestUri());
the output is http://localhost:8080/book/
My surprise is that when I look at the Location header I see http://localhost:8080/3 (3 is the id)
So it seems that between Javadoc of the spec (Response object) and the real implementation it is behaving differently. I checked the code of Resteasy and yes it seems wrong to me: URI baseUri = ((HttpRequest)ResteasyContext.getContextData(HttpRequest.class)).getUri().getBaseUri() as it gets the base URI and not the path as it happens when you call from UriInfo.