HTTPCLIENT-1162: do not override 'Accept-Encoding' header if already present
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1242782 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
747593abb7
commit
d969fe8774
|
@ -52,7 +52,9 @@ public class RequestAcceptEncoding implements HttpRequestInterceptor {
|
|||
final HttpContext context) throws HttpException, IOException {
|
||||
|
||||
/* Signal support for Accept-Encoding transfer encodings. */
|
||||
request.addHeader("Accept-Encoding", "gzip,deflate");
|
||||
if (!request.containsHeader("Accept-Encoding")) {
|
||||
request.addHeader("Accept-Encoding", "gzip,deflate");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,4 +50,17 @@ public class TestRequestAcceptEncoding {
|
|||
Assert.assertEquals("gzip,deflate", header.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptEncodingAlreadyPResent() throws Exception {
|
||||
HttpRequest request = new BasicHttpRequest("GET", "/");
|
||||
request.addHeader("Accept-Encoding", "stuff");
|
||||
HttpContext context = new BasicHttpContext();
|
||||
|
||||
HttpRequestInterceptor interceptor = new RequestAcceptEncoding();
|
||||
interceptor.process(request, context);
|
||||
Header header = request.getFirstHeader("Accept-Encoding");
|
||||
Assert.assertNotNull(header);
|
||||
Assert.assertEquals("stuff", header.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue