[resteasy] Imprecise http status code when a requested media type is not available
Yonghee Shin
syonghee at gmail.com
Wed Sep 14 16:40:25 EDT 2016
Hi,
When the requested media type in the "Accept" http header is not available
on the server side, currently http status 500 is returned instead of 406
(Not Acceptable).
I traced the code and a simple change below
in org.jboss.resteasy.springmvc.ResteasyHandlerMapping.getHandler(HttpServletRequest
request) made it return the proper code:
catch (NotFoundException e)
{
if (throwNotFound)
{
throw e;
}
logger.error("Resource Not Found: " + e.getMessage(), e);
}
catch (NotAcceptableException na) { // Added this exception handler
logger.error("Not acceptable: " + na.getMessage(), na);
requestWrapper.setError(406, "The requested media type is not
acceptable.");
return new HandlerExecutionChain(requestWrapper, interceptors);
}
catch (Failure e)
I'm using resteasy-spring-2.3.7.jar.
Is there any newer version that already addresses this issue or would it be
possible to enhance the code in the future release?
I appreciate your help.
Yonghee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/resteasy/attachments/20160914/d257218c/attachment.html
More information about the resteasy
mailing list