users@jersey.java.net

[Jersey] ApacheConnector, MessageBodyWriters and adding header fields

From: Maarten Boekhold <boekhold_at_gmx.com>
Date: Thu, 19 May 2016 09:51:04 +0400

Hi,

The Jersey documentation contains the following warning:

    Be aware of using other than default |Connector| implementation.
    There is an issue handling HTTP headers in |WriterInterceptor| or
    |MessageBodyWriter<T>|. If you need to change header fields do not
    use nor |ApacheConnectorProvider| nor |GrizzlyConnectorProvider|
    neither |JettyConnectorProvider|.

Is this really true? I have a Jersey client program that uses a custom
MessageBodyWriter that does:

         while (headers.hasNext()) {

             final MimeHeader hdr = headers.next();

             httpHeaders.add(hdr.getName(), hdr.getValue());

         }

Currently I'm using the default HttpUrlConnector, however we're having
some conflicts with authentication in the system (other parts of the
application also relying on HttpURLConnector), so I'd like to switch to
using the ApacheConnector instead. But if this warning still applies,
that would be a deal-breaker.

Regards,

Maarten