cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ian Roberts (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-1387) Support for GZIP compression of HTTP payloads
Date Mon, 23 Mar 2015 11:22:11 GMT

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

Ian Roberts commented on CXF-1387:
----------------------------------

HTTP does allow for compression of requests - the spec for the Content-Encoding header (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11)
says "If the content-coding of an entity in a request message is not acceptable to the origin
server, the server SHOULD respond with a status code of 415 (Unsupported Media Type).".  It
would be unusual for a browser to submit an unsolicited gzip request to a random server, but
in the case of web services there's often (usually?) some out-of-band information that the
client can use to know that the server it is talking to can understand compression.

> Support for GZIP compression of HTTP payloads
> ---------------------------------------------
>
>                 Key: CXF-1387
>                 URL: https://issues.apache.org/jira/browse/CXF-1387
>             Project: CXF
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Ian Roberts
>            Assignee: Daniel Kulp
>             Fix For: 2.1.2
>
>         Attachments: gzip-interceptors-v2.diff, gzip-interceptors.diff
>
>
> This patch contains a pair of interceptors I wrote to provide support for proper GZIP
compression of request and response messages.  I originally started from the configuration_interceptor
sample but the code has evolved quite a long way from there now.
> There are two separate interceptors.  GZIPInInterceptor looks in the PROTOCOL_HEADERS
for a Content-Encoding of "gzip", and if found it wraps the message's InputStream with a GZIPInputStream
to uncompress the payload.  It restores the original input stream at the end of processing
(failure to do that originally left me with lots of stale HTTP connections).
> GZIPOutInterceptor applies gzip compression to outgoing messages whose payload is larger
than a configurable threshold (default 1kB), and sets their Content-Encoding in the PROTOCOL_HEADERS
to "gzip".  Smaller messages are not compressed as it's probably not worth the overhead.
> As currently written, these interceptors are only for use on the client side (compress
the request, uncompress the response).  In my services I implement the server-side compression
outside of CXF via a servlet filter (http://sourceforge.net/projects/pjl-comp-filter), but
if you think it would be useful I can modify the interceptors to support this too - the "in"
interceptor should work as-is, the "out" one would have to be made conditional on the Accept-Encoding
header supplied in the client request.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message