This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit e9c1a0f6c49903c743f4b85a45bea5e9d05f3725 Author: Robert Lazarski <[email protected]> AuthorDate: Sun Apr 12 14:17:34 2026 -1000 AXIS2-6101 Fix double gzip decompression with HttpClient 5.6+ Starting with HC5 5.6, ContentCompressionExec decompresses gzip responses but no longer removes the Content-Encoding header (apache/httpcomponents-client@56122fd). Axis2's HTTPSender checked the response header for "gzip" and wrapped the already-decompressed stream in GZIPInputStream, causing "Not in GZIP format" errors. Fix: Add Request.getResponseContentEncoding() which checks the HttpEntity's content encoding instead of the response header. HC5's entity returns null after decompression even though the header still says "gzip". HTTPSender now calls this method instead of getResponseHeader("Content-Encoding"). Same approach as Spring WS fix (spring-projects/spring-ws@4ab0ef4). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --- .../java/org/apache/axis2/transport/http/HTTPSender.java | 9 ++++++--- .../main/java/org/apache/axis2/transport/http/Request.java | 12 ++++++++++++ .../axis2/transport/http/impl/httpclient5/RequestImpl.java | 6 ++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java index e983dd4267..ec8c9f2cff 100644 --- a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java +++ b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/HTTPSender.java @@ -253,12 +253,15 @@ public abstract class HTTPSender { if (opContext != null) { InputStream in = request.getResponseContent(); if (in != null) { - String contentEncoding = request.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING); + // AXIS2-6101: Check the entity's content encoding, not the + // response header. Starting with HttpClient 5.6, + // ContentCompressionExec decompresses gzip responses but + // no longer removes the Content-Encoding header. Checking + // the header would cause double decompression. + String contentEncoding = request.getResponseContentEncoding(); if (contentEncoding != null) { if (contentEncoding.equalsIgnoreCase(HTTPConstants.COMPRESSION_GZIP)) { in = new GZIPInputStream(in); - // If the content-encoding is identity we can basically ignore - // it. } else if (!"identity".equalsIgnoreCase(contentEncoding)) { throw new AxisFault("HTTP :" + "unsupported content-encoding of '" + contentEncoding + "' found"); diff --git a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/Request.java b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/Request.java index df4b11f829..5d1525b077 100644 --- a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/Request.java +++ b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/Request.java @@ -42,5 +42,17 @@ public interface Request { Header[] getResponseHeaders(); Map<String,String> getCookies(); InputStream getResponseContent() throws IOException; + /** + * Returns the content encoding of the response entity, or null if + * the content is not encoded (or has already been decoded by the + * HTTP client library). + * + * <p>Starting with HttpClient 5.6, ContentCompressionExec decompresses + * gzip/deflate responses but no longer removes the Content-Encoding + * response header. Callers should use this method instead of + * {@code getResponseHeader("Content-Encoding")} to avoid double + * decompression. See AXIS2-6101. + */ + String getResponseContentEncoding(); void releaseConnection(); } diff --git a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/impl/httpclient5/RequestImpl.java b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/impl/httpclient5/RequestImpl.java index 4eb6ce9f90..e3ed47fcfb 100644 --- a/modules/transport/http/src/main/java/org/apache/axis2/transport/http/impl/httpclient5/RequestImpl.java +++ b/modules/transport/http/src/main/java/org/apache/axis2/transport/http/impl/httpclient5/RequestImpl.java @@ -215,6 +215,12 @@ final class RequestImpl implements Request { return entity == null ? null : entity.getContent(); } + @Override + public String getResponseContentEncoding() { + HttpEntity entity = response.getEntity(); + return entity == null ? null : entity.getContentEncoding(); + } + @Override public void execute() throws IOException { populateHostConfiguration();
