Hi Jerome & Co.,

Here an excerpt of a class I use nearly for all projects where Restlet
is involved:

public class Headers {
    /**
     * Constructor that wraps a [EMAIL PROTECTED] 
org.restlet.data.ParameterList}.
     *
     * @param paramList The parameter list instance to wrap.
     */
    private Headers(ParameterList paramList) {
        _paramList = paramList;
    }

    /**
     * Returns a header instance that is bound to the request headers.
     *
     * @param call The [EMAIL PROTECTED] org.restlet.Call} instance to retrieve 
the 
     *              request headers from.
     * @return A headers instance that is initialized with the request headers.
     */
    public static Headers fromRequest(Call call) {
        //FIXME: Does not work with WrapperCall cf. 
http://restlet.tigris.org/issues/show_bug.cgi?id=158
        return new Headers(((HttpServerRestletCall) 
call).getConnectorCall().getRequestHeaders());
    }

    [...]
}


I looked into the example and source code of the new call converters
but they don't help me here, right?

In an arbitrary Restlet I use it like:

   Headers headers = Headers.fromRequest(call);
   if (headers.get("X-bla-bla") == null) {
      // do something
   }
   else {
      // do something
      headers.add("X-blub-blub", "FooBar");
   }

I just want the headers, nothing more, nothing less. :)

Best regards,
Lars
-- 
http://www.semagia.com

Reply via email to