hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (Resolved) (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (HTTPCLIENT-1184) unexpected org.apache.http.client.ClientProtocolException triggered
Date Fri, 20 Apr 2012 19:28:37 GMT

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1184?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Oleg Kalnichevski resolved HTTPCLIENT-1184.
-------------------------------------------

    Resolution: Invalid

This is not a client side problem. If I remove the "Mozilla/5.0 (compatible; MSIE 9.0; Windows
NT 6.1; WOW64; Trident/5.0; yie9)" user-agent header, the server responds with valid HTTP
response messages.

---
[DEBUG] PoolingClientConnectionManager - Connection request: [route: {}->http://www.amazon.fr][total
kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[DEBUG] PoolingClientConnectionManager - Connection leased: [id: 0][route: {}->http://www.amazon.fr][total
kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] DefaultClientConnectionOperator - Connecting to www.amazon.fr:80
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] RequestTargetAuthentication - Target auth state: UNCHALLENGED
[DEBUG] RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[DEBUG] headers - >> Host: www.amazon.fr
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> User-Agent: Apache-HttpClient/4.2-beta2-SNAPSHOT (java 1.5)
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
[DEBUG] headers - << HTTP/1.1 200 OK
[DEBUG] headers - << Date: Fri, 20 Apr 2012 19:23:53 GMT
[DEBUG] headers - << Server: Server
[DEBUG] headers - << pragma: no-cache
[DEBUG] headers - << x-amz-id-1: 0DMWZZ9D4HAMEVD48JFV
[DEBUG] headers - << cache-control: no-cache
[DEBUG] headers - << expires: -1
[DEBUG] headers - << x-amz-id-2: 1KLcuqxFJaoHF6VnFDCHxz2fu7lhIbQXZEBLololInr5kVP6GRxG12ylSUg4aRJn
[DEBUG] headers - << Vary: Accept-Encoding,User-Agent
[DEBUG] headers - << Content-Type: text/html; charset=ISO-8859-15
[DEBUG] headers - << Set-cookie: session-id-time=2082754801l; path=/; domain=.amazon.fr;
expires=Mon, 31-Dec-2035 23:00:01 GMT
[DEBUG] headers - << Set-cookie: session-id=277-4862602-5891451; path=/; domain=.amazon.fr;
expires=Mon, 31-Dec-2035 23:00:01 GMT
[DEBUG] headers - << Transfer-Encoding: chunked
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: session-id-time][value:
2082754801l][domain: .amazon.fr][path: /][expiry: Tue Jan 01 00:00:01 GMT+01:00 2036]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: session-id][value: 277-4862602-5891451][domain:
.amazon.fr][path: /][expiry: Tue Jan 01 00:00:01 GMT+01:00 2036]". 
[DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely
HTTP/1.1 200 OK
[DEBUG] PoolingClientConnectionManager - Connection [id: 0][route: {}->http://www.amazon.fr]
can be kept alive indefinitely
[DEBUG] PoolingClientConnectionManager - Connection released: [id: 0][route: {}->http://www.amazon.fr][total
kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] PoolingClientConnectionManager - Connection request: [route: {}->http://www.amazon.fr][total
kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] PoolingClientConnectionManager - Connection leased: [id: 0][route: {}->http://www.amazon.fr][total
kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] DefaultHttpClient - Stale connection check
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAddCookies - Cookie [version: 0][name: session-id][value: 277-4862602-5891451][domain:
.amazon.fr][path: /][expiry: Tue Jan 01 00:00:01 GMT+01:00 2036] match [www.amazon.fr:80/b/]
[DEBUG] RequestAddCookies - Cookie [version: 0][name: session-id-time][value: 2082754801l][domain:
.amazon.fr][path: /][expiry: Tue Jan 01 00:00:01 GMT+01:00 2036] match [www.amazon.fr:80/b/]
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] RequestTargetAuthentication - Target auth state: UNCHALLENGED
[DEBUG] RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[DEBUG] headers - >> Host: www.amazon.fr
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> User-Agent: Apache-HttpClient/4.2-beta2-SNAPSHOT (java 1.5)
[DEBUG] headers - >> Cookie: session-id=277-4862602-5891451; session-id-time=2082754801l
[DEBUG] headers - >> Cookie2: $Version=1
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
[DEBUG] headers - << HTTP/1.1 200 OK
[DEBUG] headers - << Date: Fri, 20 Apr 2012 19:24:00 GMT
[DEBUG] headers - << Server: Server
[DEBUG] headers - << pragma: no-cache
[DEBUG] headers - << x-amz-id-1: 01TYFV5VF8AWDCCM0J12
[DEBUG] headers - << cache-control: no-cache
[DEBUG] headers - << expires: -1
[DEBUG] headers - << x-amz-id-2: FNcyRZTYWaELRHH/02sKrvyyf13X8BsQ+mCaC+vkIPKTY5tTiIWWc07JJlid5Gyc
[DEBUG] headers - << Vary: Accept-Encoding,User-Agent
[DEBUG] headers - << Content-Type: text/html; charset=ISO-8859-15
[DEBUG] headers - << Set-cookie: ubid-acbfr=276-5249319-7380823; path=/; domain=.amazon.fr;
expires=Mon, 31-Dec-2035 23:00:01 GMT
[DEBUG] headers - << Set-cookie: session-id-time=2082754801l; path=/; domain=.amazon.fr;
expires=Mon, 31-Dec-2035 23:00:01 GMT
[DEBUG] headers - << Set-cookie: session-id=277-4862602-5891451; path=/; domain=.amazon.fr;
expires=Mon, 31-Dec-2035 23:00:01 GMT
[DEBUG] headers - << Transfer-Encoding: chunked
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: ubid-acbfr][value: 276-5249319-7380823][domain:
.amazon.fr][path: /][expiry: Tue Jan 01 00:00:01 GMT+01:00 2036]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: session-id-time][value:
2082754801l][domain: .amazon.fr][path: /][expiry: Tue Jan 01 00:00:01 GMT+01:00 2036]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: session-id][value: 277-4862602-5891451][domain:
.amazon.fr][path: /][expiry: Tue Jan 01 00:00:01 GMT+01:00 2036]". 
[DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely
HTTP/1.1 200 OK

---

When the user-agent is set, the server responds with some trailing garbage and drops connection
unexpectedly.

---
[DEBUG] PoolingClientConnectionManager - Connection request: [route: {}->http://www.amazon.fr][total
kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[DEBUG] PoolingClientConnectionManager - Connection leased: [id: 0][route: {}->http://www.amazon.fr][total
kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] DefaultClientConnectionOperator - Connecting to www.amazon.fr:80
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] RequestTargetAuthentication - Target auth state: UNCHALLENGED
[DEBUG] RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[DEBUG] headers - >> Host: www.amazon.fr
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1;
WOW64; Trident/5.0; yie9)
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
[DEBUG] headers - << HTTP/1.1 200 OK
[DEBUG] headers - << Date: Fri, 20 Apr 2012 19:26:24 GMT
[DEBUG] headers - << Server: Server
[DEBUG] headers - << x-amz-id-1: 6AD812E4B93141B4A511
[DEBUG] headers - << x-amz-id-2: zRNtkvj7d8fb13RT/d5Gxn0ld9DEXG8SK2XooKAsn1I=
[DEBUG] headers - << Content-Type: text/html;charset=UTF-8
[DEBUG] headers - << Vary: Accept-Encoding,User-Agent
[DEBUG] headers - << Set-Cookie: session-id=277-1221286-4323331; Domain=.amazon.fr;
Expires=Thu, 15-Apr-2032 19:26:24 GMT; Path=/
[DEBUG] headers - << Set-Cookie: session-id-time=1965669984l; Domain=.amazon.fr; Expires=Thu,
15-Apr-2032 19:26:24 GMT; Path=/
[DEBUG] headers - << Transfer-Encoding: chunked
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: session-id][value: 277-1221286-4323331][domain:
.amazon.fr][path: /][expiry: Thu Apr 15 20:26:24 GMT+01:00 2032]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: session-id-time][value:
1965669984l][domain: .amazon.fr][path: /][expiry: Thu Apr 15 20:26:24 GMT+01:00 2032]". 
[DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely
HTTP/1.1 200 OK
[DEBUG] PoolingClientConnectionManager - Connection [id: 0][route: {}->http://www.amazon.fr]
can be kept alive indefinitely
[DEBUG] PoolingClientConnectionManager - Connection released: [id: 0][route: {}->http://www.amazon.fr][total
kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] PoolingClientConnectionManager - Connection request: [route: {}->http://www.amazon.fr][total
kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] PoolingClientConnectionManager - Connection leased: [id: 0][route: {}->http://www.amazon.fr][total
kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] DefaultHttpClient - Stale connection check
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAddCookies - Cookie [version: 0][name: session-id][value: 277-1221286-4323331][domain:
.amazon.fr][path: /][expiry: Thu Apr 15 20:26:24 GMT+01:00 2032] match [www.amazon.fr:80/b/]
[DEBUG] RequestAddCookies - Cookie [version: 0][name: session-id-time][value: 1965669984l][domain:
.amazon.fr][path: /][expiry: Thu Apr 15 20:26:24 GMT+01:00 2032] match [www.amazon.fr:80/b/]
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] RequestTargetAuthentication - Target auth state: UNCHALLENGED
[DEBUG] RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> GET /b/?node=486048031 HTTP/1.1
[DEBUG] headers - >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[DEBUG] headers - >> Host: www.amazon.fr
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1;
WOW64; Trident/5.0; yie9)
[DEBUG] headers - >> Cookie: session-id=277-1221286-4323331; session-id-time=1965669984l
[DEBUG] headers - >> Cookie2: $Version=1
[DEBUG] DefaultResponseParser - Garbage in response: 0
[DEBUG] DefaultResponseParser - Garbage in response: 
[DEBUG] DefaultClientConnection - Connection 0.0.0.0:46840<->87.238.83.167:80 closed
[DEBUG] DefaultClientConnection - Connection 0.0.0.0:46840<->87.238.83.167:80 shut down
[DEBUG] PoolingClientConnectionManager - Connection [id: 0][route: {}->http://www.amazon.fr]
can be kept alive for 9223372036854775807 MILLISECONDS
[DEBUG] DefaultClientConnection - Connection 0.0.0.0:46840<->87.238.83.167:80 closed
[DEBUG] PoolingClientConnectionManager - Connection released: [id: 0][route: {}->http://www.amazon.fr][total
kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
---

Oleg

                
> unexpected org.apache.http.client.ClientProtocolException triggered
> -------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1184
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1184
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.1.3
>         Environment: java version "1.7.0_02"
> Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
> Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
> Linux
>            Reporter: pierz
>
> Hi, 
> When I send the 2 followings requests on www.amazon.fr, with 5 seconds wait between them,
it trigger a org.apache.http.client.ClientProtocolException, I sniffed and I did see nothing
wrong sent by the amazon server. You can reproduce the bug with the test joined.
> ---
> Logs
> ----
> ------------- Standard Output ---------------
> HTTP/1.1 200 OK
> ------------- ---------------- ---------------
> ------------- Standard Error -----------------
> 2012/04/19 21:12:35:809 CEST [DEBUG] SingleClientConnManager - Get connection for route
HttpRoute[{}->http://www.amazon.fr]
> 2012/04/19 21:12:35:817 CEST [DEBUG] DefaultClientConnectionOperator - Connecting to
www.amazon.fr:80
> 2012/04/19 21:12:35:910 CEST [DEBUG] RequestAddCookies - CookieSpec selected: best-match
> 2012/04/19 21:12:35:919 CEST [DEBUG] RequestAuthCache - Auth cache not set in the context
> 2012/04/19 21:12:35:919 CEST [DEBUG] DefaultHttpClient - Attempt 1 to execute request
> 2012/04/19 21:12:35:920 CEST [DEBUG] DefaultClientConnection - Sending request: GET /b/?node=486048031
HTTP/1.1
> 2012/04/19 21:12:35:920 CEST [DEBUG] headers - >> GET /b/?node=486048031 HTTP/1.1
> 2012/04/19 21:12:35:921 CEST [DEBUG] headers - >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> 2012/04/19 21:12:35:921 CEST [DEBUG] headers - >> Host: www.amazon.fr
> 2012/04/19 21:12:35:921 CEST [DEBUG] headers - >> Connection: Keep-Alive
> 2012/04/19 21:12:35:921 CEST [DEBUG] headers - >> User-Agent: Mozilla/5.0 (compatible;
MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; yie9)
> 2012/04/19 21:12:36:177 CEST [DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1
200 OK
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << HTTP/1.1 200 OK
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << Date: Thu, 19 Apr 2012 19:12:35
GMT
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << Server: Server
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << x-amz-id-1: B11EC0C415E04F168007
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << x-amz-id-2: RtNOi7MOVlKdI28FuzIJEpTzEIdTgcex6LtMuzWE+x4=
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << Content-Type: text/html;charset=UTF-8
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << Vary: Accept-Encoding,User-Agent
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << Set-Cookie: session-id=276-4057542-1754032;
Domain=.amazon.fr; Expires=Wed, 14-Apr-2032 19:12:36 GMT; Path=/
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << Set-Cookie: session-id-time=1965582756l;
Domain=.amazon.fr; Expires=Wed, 14-Apr-2032 19:12:36 GMT; Path=/
> 2012/04/19 21:12:36:177 CEST [DEBUG] headers - << Transfer-Encoding: chunked
> 2012/04/19 21:12:36:187 CEST [DEBUG] ResponseProcessCookies - Cookie accepted: "[version:
0][name: session-id][value: 276-4057542-1754032][domain: .amazon.fr][path: /][expiry: Wed
Apr 14 21:12:36 CEST 2032]". 
> 2012/04/19 21:12:36:187 CEST [DEBUG] ResponseProcessCookies - Cookie accepted: "[version:
0][name: session-id-time][value: 1965582756l][domain: .amazon.fr][path: /][expiry: Wed Apr
14 21:12:36 CEST 2032]". 
> 2012/04/19 21:12:36:187 CEST [DEBUG] DefaultHttpClient - Connection can be kept alive
indefinitely
> 2012/04/19 21:12:36:915 CEST [DEBUG] SingleClientConnManager - Releasing connection org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter@3787efea
> 2012/04/19 21:12:41:916 CEST [DEBUG] SingleClientConnManager - Get connection for route
HttpRoute[{}->http://www.amazon.fr]
> 2012/04/19 21:12:41:918 CEST [DEBUG] DefaultHttpClient - Stale connection check
> 2012/04/19 21:12:41:919 CEST [DEBUG] RequestAddCookies - CookieSpec selected: best-match
> 2012/04/19 21:12:41:920 CEST [DEBUG] RequestAddCookies - Cookie [version: 0][name: session-id][value:
276-4057542-1754032][domain: .amazon.fr][path: /][expiry: Wed Apr 14 21:12:36 CEST 2032] match
[www.amazon.fr:80/b/]
> 2012/04/19 21:12:41:920 CEST [DEBUG] RequestAddCookies - Cookie [version: 0][name: session-id-time][value:
1965582756l][domain: .amazon.fr][path: /][expiry: Wed Apr 14 21:12:36 CEST 2032] match [www.amazon.fr:80/b/]
> 2012/04/19 21:12:41:922 CEST [DEBUG] RequestAuthCache - Auth cache not set in the context
> 2012/04/19 21:12:41:922 CEST [DEBUG] DefaultHttpClient - Attempt 1 to execute request
> 2012/04/19 21:12:41:922 CEST [DEBUG] DefaultClientConnection - Sending request: GET /b/?node=486048031
HTTP/1.1
> 2012/04/19 21:12:41:923 CEST [DEBUG] headers - >> GET /b/?node=486048031 HTTP/1.1
> 2012/04/19 21:12:41:923 CEST [DEBUG] headers - >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> 2012/04/19 21:12:41:923 CEST [DEBUG] headers - >> Host: www.amazon.fr
> 2012/04/19 21:12:41:923 CEST [DEBUG] headers - >> Connection: Keep-Alive
> 2012/04/19 21:12:41:923 CEST [DEBUG] headers - >> User-Agent: Mozilla/5.0 (compatible;
MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; yie9)
> 2012/04/19 21:12:41:924 CEST [DEBUG] headers - >> Cookie: session-id=276-4057542-1754032;
session-id-time=1965582756l
> 2012/04/19 21:12:41:924 CEST [DEBUG] headers - >> Cookie2: $Version=1
> 2012/04/19 21:12:41:924 CEST [DEBUG] DefaultResponseParser - Garbage in response: 0
> 2012/04/19 21:12:41:925 CEST [DEBUG] DefaultResponseParser - Garbage in response: 
> 2012/04/19 21:12:41:925 CEST [DEBUG] DefaultClientConnection - Connection closed
> 2012/04/19 21:12:41:925 CEST [DEBUG] DefaultClientConnection - Connection shut down
> 2012/04/19 21:12:41:925 CEST [DEBUG] SingleClientConnManager - Releasing connection org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter@63388a78
> ------------- ---------------- ---------------
> Testcase: testApp(jacky.AppTest):	Caused an ERROR
> null
> org.apache.http.client.ClientProtocolException
> 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:822)
> 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
> 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
> 	at jacky.AppTest.testApp(AppTest.java:83)
> Caused by: org.apache.http.ProtocolException: The server failed to respond with a valid
HTTP response
> 	at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:109)
> 	at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)
> 	at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:282)
> 	at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
> 	at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:216)
> 	at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:298)
> 	at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
> 	at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:647)
> 	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
> 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
> ---
> Test.java
> ---
> package jacky.bhdownloader;
> import java.io.IOException;
> import java.util.ArrayList;
> import java.util.Iterator;
> import junit.framework.Test;
> import junit.framework.TestCase;
> import junit.framework.TestSuite;
> import org.apache.http.Header;
> import org.apache.http.HttpResponse;
> import org.apache.http.client.HttpClient;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.impl.client.DefaultHttpClient;
> import org.apache.http.message.BasicHeader;
> /**
>  * Unit test for simple App.
>  */
> public class AppTest 
>     extends TestCase
> {
>     /**
>      * Create the test case
>      *
>      * @param testName name of the test case
>      */
>     public AppTest( String testName )
>     {
>         super( testName );
>     }
>     /**
>      * @return the suite of tests being tested
>      */
>     public static Test suite()
>     {
>         return new TestSuite( AppTest.class );
>     }
>     
>     public static void setHeader(HttpClient httpclient,String name, String value, boolean
bOverride){
>         if(name != null && value != null && httpclient != null){
>             ArrayList<Header> headers = (ArrayList<Header>)httpclient.getParams().getParameter("http.default-headers");
>             if(headers == null)
>                 headers = new ArrayList<>();
>             if(bOverride){
>                 Iterator<Header> it = headers.iterator();
>                 while(it.hasNext()){
>                     Header header = it.next();
>                     if(header.getName().equalsIgnoreCase(name)){
>                         it.remove();
>                     }
>                 }
>             }
>             headers.add(new BasicHeader(name,value));
>             httpclient.getParams().setParameter("http.default-headers", headers);
>         }
>     }
>     /**
>      * Rigourous Test :-)
>      */
>     public void testApp() throws IOException, InterruptedException
>     {
>         System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
>         System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
>         System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http",
"DEBUG");        
>         System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire",
"ERROR");  
>         
>         HttpClient httpclient = new DefaultHttpClient();
>         httpclient.getParams().setParameter("http.useragent", "Mozilla/5.0 (compatible;
MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; yie9)");
>         setHeader(httpclient, "Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
true);
>         
>         HttpGet get = new HttpGet("http://www.amazon.fr/b/?node=486048031");
>         HttpResponse execute = httpclient.execute(get);
>         System.out.println(execute.getStatusLine());
>         execute.getEntity().consumeContent();
>         
>         Thread.sleep(5000l);
>         
>         get = new HttpGet("http://www.amazon.fr/b/?node=486048031");
>         execute = httpclient.execute(get);
>         System.out.println(execute.getStatusLine());        
>         
>     }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


Mime
View raw message