users@jersey.java.net

Re: [Jersey] getting the allowed methods from the apache http client api

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 23 Mar 2009 08:27:57 +0100

On Mar 20, 2009, at 5:26 PM, Arul Dhesiaseelan wrote:

> I am trying to invoke OPTIONS method on the ApacheHttpClient API and
> I am getting the ClientResponse with all the allowedMethods, but
> there is no API to get the supported methods from HttpClientResponse
> in ApacheHttpClientHandler.
> Is there a way to get the list of allowed methods from the
> ClientResponse?
>

You can get the "Allow" HTTP header directly and parse it yourself.

   ClientResponse cr = ...
   String allow = cr.getMetadata().getFirst("Allow");

I think we should deprecate getMetadata and have getHeaders instead.

I suppose we could have something like:

   List<String> getAllow();

on ClientResponse? Is that what you want?

Paul.