users@jax-rs-spec.java.net

[jax-rs-spec users] Question about Response.created()

From: Ron Sigal <rsigal_at_redhat.com>
Date: Wed, 4 May 2016 14:53:18 -0400

Hi,

This question comes from https://issues.jboss.org/browse/RESTEASY-1162,
where the reporter points out that the javadoc for
javax.ws.rs.core.Response.created() says that passing in a relative URI
causes it to be resolved against the */request URI:/*

         /**
          * Create a new ResponseBuilder for a created resource, set the
    location
          * header using the supplied value.
          *
          * @param location 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 {_at_link
    UriInfo#getRequestUri}).
          * @return a new response builder.
          * @throws java.lang.IllegalArgumentException
          * if location is {_at_code null}.
          */
         public static ResponseBuilder created(URI location) {
             return status(Status.CREATED).location(location);
         }

but the javadoc for javax.ws.rs.core.Response$ResponseBuilder.location()
says that passing in a relative URI causes it to be resolved against the
/*base URI:

*/

             /**
              * Set the location.
              *
              * @param location the location. If a relative URI is
    supplied it will be
              * converted into an absolute URI by
    resolving it relative to the
              * base URI of the application (see {_at_link
    UriInfo#getBaseUri}).
              * If {_at_code null} any existing value for
    location will be removed.
              * @return the updated response builder.
              */
             public abstract ResponseBuilder location(URI location);

Which is it?

Thanks,
Ron

-- 
My company's smarter than your company (unless you work for Red Hat)