HTTPCLIENT-1063: treat x-gzip as a synonym for gzip

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1074481 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2011-02-25 11:51:12 +00:00
parent a572756592
commit 56211032bf
1 changed files with 8 additions and 6 deletions

View File

@ -27,6 +27,7 @@
package org.apache.http.client.protocol;
import java.io.IOException;
import java.util.Locale;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
@ -52,17 +53,17 @@ import org.apache.http.protocol.HttpContext;
public class ResponseContentEncoding implements HttpResponseInterceptor {
/**
* Handles the following {@code Content-Encoding}s by
* Handles the following {@code Content-Encoding}s by
* using the appropriate decompressor to wrap the response Entity:
* <ul>
* <li>gzip - see {@link GzipDecompressingEntity}</li>
* <li>deflate - see {@link DeflateDecompressingEntity}</li>
* <li>identity - no action needed</li>
* </ul>
*
*
* @param response the response which contains the entity
* @param context not currently used
*
*
* @throws HttpException if the {@code Content-Encoding} is none of the above
*/
public void process(
@ -76,13 +77,14 @@ public class ResponseContentEncoding implements HttpResponseInterceptor {
if (ceheader != null) {
HeaderElement[] codecs = ceheader.getElements();
for (HeaderElement codec : codecs) {
if ("gzip".equalsIgnoreCase(codec.getName())) {
String codecname = codec.getName().toLowerCase(Locale.US);
if ("gzip".equals(codecname) || "x-gzip".equals(codecname)) {
response.setEntity(new GzipDecompressingEntity(response.getEntity()));
return;
} else if ("deflate".equalsIgnoreCase(codec.getName())) {
} else if ("deflate".equals(codecname)) {
response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
return;
} else if ("identity".equalsIgnoreCase(codec.getName())) {
} else if ("identity".equals(codecname)) {
/* Don't need to transform the content - no-op */
return;