hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1564) ContentEncodingHttpClient 4.3.5 breaks compat with 4.2.5
Date Fri, 10 Oct 2014 18:30:34 GMT

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

Gary Gregory commented on HTTPCLIENT-1564:
------------------------------------------

Thanks Oleg,

Using the client v4.3.5 and my 4.2.5-based testCompressionSanityCheck (no builders), I see:

{noformat}
2014-10-10 14:20:39,161 [main] DEBUG - Get connection for route {}->http://172.16.39.188:58070
2014-10-10 14:20:39,177 [main] DEBUG - Connecting to 172.16.39.188:58070
2014-10-10 14:20:39,216 [main] DEBUG - CookieSpec selected: best-match
2014-10-10 14:20:39,233 [main] DEBUG - Auth cache not set in the context
2014-10-10 14:20:39,233 [main] DEBUG - Target auth state: UNCHALLENGED
2014-10-10 14:20:39,235 [main] DEBUG - Proxy auth state: UNCHALLENGED
2014-10-10 14:20:39,235 [main] DEBUG - Attempt 1 to execute request
2014-10-10 14:20:39,235 [main] DEBUG - Sending request: GET /files/BigHelloWorld.txt HTTP/1.1
2014-10-10 14:20:39,235 [main] DEBUG -  >> "GET /files/BigHelloWorld.txt HTTP/1.1[\r][\n]"
2014-10-10 14:20:39,237 [main] DEBUG -  >> "Host: 172.16.39.188:58070[\r][\n]"
2014-10-10 14:20:39,237 [main] DEBUG -  >> "Connection: Keep-Alive[\r][\n]"
2014-10-10 14:20:39,237 [main] DEBUG -  >> "User-Agent: Apache-HttpClient/4.3.5 (java
1.5)[\r][\n]"
2014-10-10 14:20:39,237 [main] DEBUG -  >> "Accept-Encoding: gzip,deflate[\r][\n]"
2014-10-10 14:20:39,237 [main] DEBUG -  >> "[\r][\n]"
2014-10-10 14:20:39,237 [main] DEBUG - >> GET /files/BigHelloWorld.txt HTTP/1.1
2014-10-10 14:20:39,237 [main] DEBUG - >> Host: 172.16.39.188:58070
2014-10-10 14:20:39,237 [main] DEBUG - >> Connection: Keep-Alive
2014-10-10 14:20:39,237 [main] DEBUG - >> User-Agent: Apache-HttpClient/4.3.5 (java
1.5)
2014-10-10 14:20:39,237 [main] DEBUG - >> Accept-Encoding: gzip,deflate
2014-10-10 14:20:39,283 [main] DEBUG -  << "HTTP/1.1 200 OK[\r][\n]"
2014-10-10 14:20:39,285 [main] DEBUG -  << "Content-Type: text/plain[\r][\n]"
2014-10-10 14:20:39,286 [main] DEBUG -  << "Last-Modified: Thu, 28 Mar 2013 16:02:36
GMT[\r][\n]"
2014-10-10 14:20:39,286 [main] DEBUG -  << "Accept-Ranges: bytes[\r][\n]"
2014-10-10 14:20:39,286 [main] DEBUG -  << "Content-Encoding: gzip[\r][\n]"
2014-10-10 14:20:39,286 [main] DEBUG -  << "Vary: Accept-Encoding, User-Agent[\r][\n]"
2014-10-10 14:20:39,286 [main] DEBUG -  << "Content-Length: 696[\r][\n]"
2014-10-10 14:20:39,286 [main] DEBUG -  << "Server: Jetty(8.1.15.v20140411)[\r][\n]"
2014-10-10 14:20:39,286 [main] DEBUG -  << "[\r][\n]"
2014-10-10 14:20:39,287 [main] DEBUG - Receiving response: HTTP/1.1 200 OK
2014-10-10 14:20:39,287 [main] DEBUG - << HTTP/1.1 200 OK
2014-10-10 14:20:39,287 [main] DEBUG - << Content-Type: text/plain
2014-10-10 14:20:39,287 [main] DEBUG - << Last-Modified: Thu, 28 Mar 2013 16:02:36 GMT
2014-10-10 14:20:39,287 [main] DEBUG - << Accept-Ranges: bytes
2014-10-10 14:20:39,287 [main] DEBUG - << Content-Encoding: gzip
2014-10-10 14:20:39,287 [main] DEBUG - << Vary: Accept-Encoding, User-Agent
2014-10-10 14:20:39,287 [main] DEBUG - << Content-Length: 696
2014-10-10 14:20:39,287 [main] DEBUG - << Server: Jetty(8.1.15.v20140411)
{noformat}

Switching from:

{code:java}
final DefaultHttpClient httpClient = new ContentEncodingHttpClient();
HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 5000);
{code}

to:

{code:java}
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
{code}

I get:

{noformat}
2014-10-10 14:22:22,925 [main] DEBUG - CookieSpec selected: best-match
2014-10-10 14:22:22,941 [main] DEBUG - Auth cache not set in the context
2014-10-10 14:22:22,942 [main] DEBUG - Connection request: [route: {}->http://172.16.39.188:58070][total
kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2014-10-10 14:22:22,976 [main] DEBUG - Connection leased: [id: 0][route: {}->http://172.16.39.188:58070][total
kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2014-10-10 14:22:22,980 [main] DEBUG - Opening connection {}->http://172.16.39.188:58070
2014-10-10 14:22:22,983 [main] DEBUG - Connecting to /172.16.39.188:58070
2014-10-10 14:22:22,989 [main] DEBUG - Connection established 172.16.39.188:61034<->172.16.39.188:58070
2014-10-10 14:22:22,989 [main] DEBUG - Executing request GET /files/BigHelloWorld.txt HTTP/1.1
2014-10-10 14:22:22,989 [main] DEBUG - Target auth state: UNCHALLENGED
2014-10-10 14:22:22,990 [main] DEBUG - Proxy auth state: UNCHALLENGED
2014-10-10 14:22:22,992 [main] DEBUG - http-outgoing-0 >> GET /files/BigHelloWorld.txt
HTTP/1.1
2014-10-10 14:22:22,992 [main] DEBUG - http-outgoing-0 >> Host: 172.16.39.188:58070
2014-10-10 14:22:22,992 [main] DEBUG - http-outgoing-0 >> Connection: Keep-Alive
2014-10-10 14:22:22,992 [main] DEBUG - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.5
(java 1.5)
2014-10-10 14:22:22,992 [main] DEBUG - http-outgoing-0 >> Accept-Encoding: gzip,deflate
2014-10-10 14:22:22,992 [main] DEBUG - http-outgoing-0 >> "GET /files/BigHelloWorld.txt
HTTP/1.1[\r][\n]"
2014-10-10 14:22:22,992 [main] DEBUG - http-outgoing-0 >> "Host: 172.16.39.188:58070[\r][\n]"
2014-10-10 14:22:22,993 [main] DEBUG - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2014-10-10 14:22:22,993 [main] DEBUG - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.5
(java 1.5)[\r][\n]"
2014-10-10 14:22:22,993 [main] DEBUG - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2014-10-10 14:22:22,993 [main] DEBUG - http-outgoing-0 >> "[\r][\n]"
2014-10-10 14:22:23,090 [main] DEBUG - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
2014-10-10 14:22:23,090 [main] DEBUG - http-outgoing-0 << "Content-Type: text/plain[\r][\n]"
2014-10-10 14:22:23,090 [main] DEBUG - http-outgoing-0 << "Last-Modified: Thu, 28 Mar
2013 16:02:36 GMT[\r][\n]"
2014-10-10 14:22:23,090 [main] DEBUG - http-outgoing-0 << "Accept-Ranges: bytes[\r][\n]"
2014-10-10 14:22:23,090 [main] DEBUG - http-outgoing-0 << "Content-Encoding: gzip[\r][\n]"
2014-10-10 14:22:23,091 [main] DEBUG - http-outgoing-0 << "Vary: Accept-Encoding, User-Agent[\r][\n]"
2014-10-10 14:22:23,091 [main] DEBUG - http-outgoing-0 << "Content-Length: 696[\r][\n]"
2014-10-10 14:22:23,091 [main] DEBUG - http-outgoing-0 << "Server: Jetty(8.1.15.v20140411)[\r][\n]"
2014-10-10 14:22:23,091 [main] DEBUG - http-outgoing-0 << "[\r][\n]"
2014-10-10 14:22:23,091 [main] DEBUG - http-outgoing-0 << "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0xed][0xce][0xb1][\n]"
2014-10-10 14:22:23,091 [main] DEBUG - http-outgoing-0 << "[0x82]`[0x18][0x5][0xd0]=[0xe8][0x1d][0xbe][0xc0][0xd5][0xf8][0xf5][0xaf]([0xc7]&{[0x82][0xa0]Y[0x91]@[0x10][0xc4][0xa1][0xde]>[0xf2][0x1d][0xa2][0xe5]p[0xa7][0xcb][0x1d][0xee]i[0xfb]q[0x9c][0xe2]>[0xcd]c[0xb7][0x8b][0xf6][0xf]e[0xbb][0xf9][0xc7]+[0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0x2][0xc2]/[0x9][0xdf][0x14][0xb7][0xae][0x89][0xeb]sX[0x97]u[0xd8]/[0xaf]%r:[0x1e]R[0xd4][0xa9][0xca]e[0xca]e}[0x8e][0xea][0xd4][0xa4][0xba][0xc9][0x97]G[0xc][0xc3][0xdc][0xf][0xd3][0xfc][0x8e][0xe2][0x3][0x4][0xcf][0xe9][0xb8][0x13]F[0x2][0x0]"
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << HTTP/1.1 200 OK
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << Content-Type: text/plain
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << Last-Modified: Thu, 28 Mar
2013 16:02:36 GMT
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << Accept-Ranges: bytes
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << Content-Encoding: gzip
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << Vary: Accept-Encoding, User-Agent
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << Content-Length: 696
2014-10-10 14:22:23,096 [main] DEBUG - http-outgoing-0 << Server: Jetty(8.1.15.v20140411)
2014-10-10 14:22:23,102 [main] DEBUG - Connection can be kept alive indefinitely
2014-10-10 14:22:23,116 [main] DEBUG - Connection manager is shutting down
2014-10-10 14:22:23,116 [main] DEBUG - http-outgoing-0: Close connection
2014-10-10 14:22:23,117 [main] DEBUG - http-outgoing-0: Close connection
2014-10-10 14:22:23,117 [main] DEBUG - Connection manager shut down
{noformat}

The {{Content-Encoding}} header is there in both cases but it is not available through {{response.getFirstHeader(HttpHeaders.CONTENT_ENCODING)}}

I cannot debug ATM. Any insight is appreciated.

Thank you,
Gary

> ContentEncodingHttpClient 4.3.5 breaks compat with 4.2.5 
> ---------------------------------------------------------
>
>                 Key: HTTPCLIENT-1564
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1564
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3.5
>         Environment: Java version: 1.7.0_67, vendor: Oracle Corporation
> Java home: C:\Program Files\Java\jdk1.7.0_67\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
>            Reporter: Gary Gregory
>
> I have a test that fails after updating from 4.2.5 to 4.3.5.
> The test looks like this:
> {code:java}
>     public void testCompressionSanityCheck() throws IOException {
>         final DefaultHttpClient client = new ContentEncodingHttpClient();
>         HttpConnectionParams.setConnectionTimeout(client.getParams(), 5000);
>         final HttpGet request = new HttpGet(getServerUrlStringForFiles() + "/BigHelloWorld.txt");
>         final HttpResponse response = client.execute(request);
>         // check that response is compressed
>         final Header h = response.getFirstHeader(HttpHeaders.CONTENT_ENCODING);
>         if (h != null) {
>             LOG.info("Response is " + h.getValue() + " encoded");
>         } else {
>             Assert.fail("Response is not encoded");
>         }
>         final HttpEntity entity = response.getEntity();
>         // decompress
>         final byte[] content = EntityUtils.toByteArray(entity);
>         Assert.assertEquals(149011, content.length);
>         // check that contents is OK
>         ImageIO.read(new ByteArrayInputStream(content));
>     }
> {code}
> The server side is a custom servlet running in Jetty 8.1.15.
> The failure:
> {noformat}
> java.lang.AssertionError: Response is not encoded
> 	at org.junit.Assert.fail(Assert.java:88)
> 	at com.seagullsw.appinterface.server.comm.jetty.JettyHttpCompressedContentTestCase.testCompressionSanityCheck(JettyHttpCompressedContentTestCase.java:179)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> 	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
> 	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> 	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> 	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
> 	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
> 	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
> {noformat}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message