You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@wink.apache.org by Bryant Luk <br...@gmail.com> on 2010/01/27 23:48:13 UTC

Re: Handling HTTP 405 error code

Hi Lior,

I believe this is a bug in Wink since we should generate the 405
information for you.  Can you open a bug in JIRA and report it (
http://issues.apache.org/jira/browse/WINK )?  If not, I'll open a JIRA
tomorrow.  If you ever need to generate the status code manually, you
can always call Response.status(405).header(..., ...).

Thanks.

On Wed, Jan 27, 2010 at 3:16 AM, Harel, Lior <li...@hp.com> wrote:
> Hi,
>
> I am having troubles handling wrong method calls. When calling a resource with inappropriate method (e.g. POST instead of GET), wink identifies the resource doesn't support the requested method, and generates a WebApplicationException with status code 405. (so far so good :-) )
> For some reason the http error code 405 is not part of the Status class, so calling valueOf doesn't generate the appropriate Status object instance. I guess that's not a wink issue, as it is not part of the javax.ws.rs spec either.
>
> The HTP spec says that when returning 405 error, the server also MUST set the Allow header. Taken from w3 HTTP 1.1 Spec :
>
> ----
>
> 10.4.6 405 Method Not Allowed
>
> The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header
> containing a list of valid methods for the requested resource.
>
> ----
>
> Do you have any idea how do I build the appropriate response object for this case (setting the Allow header with relevant values)? Does wink have anything out of the box to handle it?
>
> Thanks,
> Lior
>

RE: Handling HTTP 405 error code

Posted by "Harel, Lior" <li...@hp.com>.
Thanks for your answer.

Returning the appropriate error code is trivial as you said... the problem is setting the Allow header with the relevant values (e.g. Allow: GET,POST). We centralized the exception handling logic into the exception mapper, when a method not allowed exception is thrown it is difficult to tell what are the supported methods of the requested resource.

Anyways, I opened a bug: https://issues.apache.org/jira/browse/WINK-251


Thanks,
Lior

-----Original Message-----
From: Bryant Luk [mailto:bryant.luk@gmail.com] 
Sent: יום ה 28 ינואר 2010 00:48
To: wink-user@incubator.apache.org
Subject: Re: Handling HTTP 405 error code

Hi Lior,

I believe this is a bug in Wink since we should generate the 405
information for you.  Can you open a bug in JIRA and report it (
http://issues.apache.org/jira/browse/WINK )?  If not, I'll open a JIRA
tomorrow.  If you ever need to generate the status code manually, you
can always call Response.status(405).header(..., ...).

Thanks.

On Wed, Jan 27, 2010 at 3:16 AM, Harel, Lior <li...@hp.com> wrote:
> Hi,
>
> I am having troubles handling wrong method calls. When calling a resource with inappropriate method (e.g. POST instead of GET), wink identifies the resource doesn't support the requested method, and generates a WebApplicationException with status code 405. (so far so good :-) )
> For some reason the http error code 405 is not part of the Status class, so calling valueOf doesn't generate the appropriate Status object instance. I guess that's not a wink issue, as it is not part of the javax.ws.rs spec either.
>
> The HTP spec says that when returning 405 error, the server also MUST set the Allow header. Taken from w3 HTTP 1.1 Spec :
>
> ----
>
> 10.4.6 405 Method Not Allowed
>
> The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header
> containing a list of valid methods for the requested resource.
>
> ----
>
> Do you have any idea how do I build the appropriate response object for this case (setting the Allow header with relevant values)? Does wink have anything out of the box to handle it?
>
> Thanks,
> Lior
>