cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ka-Lok Fung (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-3822) JAX-RS: A 406 status could should be returned for an improperly formatted Accept header
Date Mon, 26 Sep 2011 01:51:26 GMT

    [ https://issues.apache.org/jira/browse/CXF-3822?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13114432#comment-13114432
] 

Ka-Lok Fung commented on CXF-3822:
----------------------------------

So the best spec would be [RFC2616: Hypertext Transfer Protocol -- HTTP/1.1|http://www.ietf.org/rfc/rfc2616.txt].

According to the spec, the Accept header needs to meet the following specification:

{noformat}
       media-range    = ( "*/*"
                        | ( type "/" "*" )
                        | ( type "/" subtype )
                        ) *( ";" parameter )
{noformat}

Looking at the above, it looks like the slash is mandatory.

[RFC2616|http://www.ietf.org/rfc/rfc2616.txt] also states the following:

{noformat}
If an Accept header field is present,
and if the server cannot send a response which is acceptable
according to the combined Accept field value, then the server SHOULD
send a 406 (not acceptable) response.
{noformat}

This leads me to believe that 406 is the appropriate response to send to the client. However,
the missing slash is also a client side error so 400 could be an appropriate response as well.

At the end of the day, just pick one. Either one would be better than the 500 that's there
right now :-)

> JAX-RS: A 406 status could should be returned for an improperly formatted Accept header
> ---------------------------------------------------------------------------------------
>
>                 Key: CXF-3822
>                 URL: https://issues.apache.org/jira/browse/CXF-3822
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.3.6, 2.4.2
>         Environment: Java 1.6
>            Reporter: Ka-Lok Fung
>            Priority: Minor
>             Fix For: 2.3.7, 2.4.3, 2.5
>
>         Attachments: cxf3822.trunk.patch.diff
>
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> If you send an Accept header that doesn't contain a slash (i.e., /), CXF's JAX-RS implementation
returns a HTTP status of 500 (Internal Server Error). Instead of this status, it would be
preferred if a HTTP status of 406 (Not Acceptable) is returned.
> Here's the test header:
> bq. {{Accept: foo}}
> Here's the current response:
> bq. {{Status Code: 500 org.apache.cxf.interceptor.Fault: Media type separator is missing}}
> Here's the preferred response:
> bq. {{Status Code: 406 Not Acceptable}}
> I've attached a potential patch against trunk for this issue:

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message