public ServerResponse invoke(HttpRequest request, HttpResponse response, Object target) { request.setAttribute(ResourceMethod.class.getName(), this); incrementMethodCount(request.getHttpMethod()); UriInfoImpl uriInfo = (UriInfoImpl) request.getUri(); uriInfo.pushCurrentResource(target); try { ServerResponse jaxrsResponse = invokeOnTarget(request, response, target); if (jaxrsResponse != null && jaxrsResponse.getEntity() != null) { // if the content type isn't set, then set it to be either most desired type from the Accept // header // or the first media type in the @Produces annotation // See RESTEASY-144 Object type = jaxrsResponse.getMetadata().getFirst(HttpHeaderNames.CONTENT_TYPE); if (type == null) jaxrsResponse .getMetadata() .putSingle( HttpHeaderNames.CONTENT_TYPE, resolveContentType(request, jaxrsResponse.getEntity())); } return jaxrsResponse; } finally { uriInfo.popCurrentResource(); } }
public RESTEasyRequestWrapper(Request request, String prefix) { this.request = request; headers = ServletUtil.extractHttpHeaders(request); uriInfo = ServletUtil.extractUriInfo(request, prefix); preProcessedPath = uriInfo.getPath(false); }