You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2020/09/05 15:21:25 UTC

[GitHub] [httpcomponents-client] DarrenLuo edited a comment on pull request #254: handle the request's path error when using system proxy

DarrenLuo edited a comment on pull request #254:
URL: https://github.com/apache/httpcomponents-client/pull/254#issuecomment-687624589


   I simplify this code, and adjust the log level, only log `org.apache.hc.client5.http.headers`
   
   the code like this:
   
   ```java
   public static void main(String[] args) throws IOException {
       CookieStore cookieStore = new BasicCookieStore();
       BasicClientCookie cookie = new BasicClientCookie("test", "test");
       cookie.setDomain("cn.bing.com");
       cookie.setPath("/");
       cookieStore.addCookie(cookie);
   
       log.info("request no proxy: ");
   
       Request request = Request.get("http://cn.bing.com");
       Executor.newInstance()
               .use(cookieStore)
               .execute(request);
   
       log.info("request with proxy: ");
   
       Request requestThroughProxy = Request.get("http://cn.bing.com")
               .viaProxy("192.168.31.145:10809");
       Executor.newInstance()
               .use(cookieStore)
               .execute(requestThroughProxy);
   }
   ```
   
   the log is: 
   ```log
   2020-09-05 23:11:38.532  INFO 10485 --- [lication Thread] xyz.darrenluo.front.IndexController      : request no proxy: 
   2020-09-05 23:11:38.762 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 >> GET / HTTP/1.1
   2020-09-05 23:11:38.762 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 >> Accept-Encoding: gzip, x-gzip, deflate
   2020-09-05 23:11:38.763 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 >> Host: cn.bing.com
   2020-09-05 23:11:38.763 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 >> Connection: keep-alive
   2020-09-05 23:11:38.763 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 >> User-Agent: Apache-HttpClient/5.0.1 (Java/14.0.2)
   2020-09-05 23:11:38.763 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 >> Cookie: test=test
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << HTTP/1.1 200 OK
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Cache-Control: private, max-age=0
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Content-Length: 50197
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Content-Type: text/html; charset=utf-8
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Content-Encoding: gzip
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Vary: Accept-Encoding
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: SRCHD=AF=NOFORM; domain=.bing.com; expires=Mon, 05-Sep-2022 15:12:13 GMT; path=/
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: SRCHUID=V=2&GUID=E44E11C37DE441DFA5940BAE884596BC&dmnchg=1; domain=.bing.com; expires=Mon, 05-Sep-2022 15:12:13 GMT; path=/
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: SRCHUSR=DOB=20200905; domain=.bing.com; expires=Mon, 05-Sep-2022 15:12:13 GMT; path=/
   2020-09-05 23:11:38.865 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: _SS=SID=2E8C407D0B98662F2D5F4F410AB6672F; domain=.bing.com; path=/
   2020-09-05 23:11:38.866 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << X-MSEdge-Ref: Ref A: BE500D3E6E4540FC8ACB3C378D68DB63 Ref B: BJ1EDGE0211 Ref C: 2020-09-05T15:12:13Z
   2020-09-05 23:11:38.866 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: _EDGE_S=F=1&SID=2E8C407D0B98662F2D5F4F410AB6672F; path=/; httponly; domain=bing.com
   2020-09-05 23:11:38.866 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: _EDGE_V=1; path=/; httponly; expires=Thu, 30-Sep-2021 15:12:13 GMT; domain=bing.com
   2020-09-05 23:11:38.866 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: MUID=0AFCAD618379630E0B1CA25D825762D3; samesite=none; path=/; secure; expires=Thu, 30-Sep-2021 15:12:13 GMT; domain=bing.com
   2020-09-05 23:11:38.866 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Set-Cookie: MUIDB=0AFCAD618379630E0B1CA25D825762D3; path=/; httponly; expires=Thu, 30-Sep-2021 15:12:13 GMT
   2020-09-05 23:11:38.866 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-0 << Date: Sat, 05 Sep 2020 15:12:13 GMT
   2020-09-05 23:11:38.887  INFO 10485 --- [lication Thread] xyx.darrenluo.front.IndexController      : request with proxy: 
   2020-09-05 23:11:45.729 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 >> GET http://cn.bing.com/ HTTP/1.1
   2020-09-05 23:11:45.729 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 >> Accept-Encoding: gzip, x-gzip, deflate
   2020-09-05 23:11:45.729 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 >> Host: cn.bing.com
   2020-09-05 23:11:45.729 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 >> User-Agent: Apache-HttpClient/5.0.1 (Java/14.0.2)
   2020-09-05 23:11:47.396 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << HTTP/1.1 200 OK
   2020-09-05 23:11:47.396 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Content-Length: 50189
   2020-09-05 23:11:47.396 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Cache-Control: private, max-age=0
   2020-09-05 23:11:47.396 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Connection: keep-alive
   2020-09-05 23:11:47.396 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Content-Encoding: gzip
   2020-09-05 23:11:47.396 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Content-Type: text/html; charset=utf-8
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Date: Sat, 05 Sep 2020 15:12:21 GMT
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Keep-Alive: timeout=4
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << P3p: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Proxy-Connection: keep-alive
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: SRCHD=AF=NOFORM; domain=.bing.com; expires=Mon, 05-Sep-2022 15:12:21 GMT; path=/
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: SRCHUID=V=2&GUID=CC885652695145E887299DF256097783&dmnchg=1; domain=.bing.com; expires=Mon, 05-Sep-2022 15:12:21 GMT; path=/
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: SRCHUSR=DOB=20200905; domain=.bing.com; expires=Mon, 05-Sep-2022 15:12:21 GMT; path=/
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: _SS=SID=01BC6F54CDD16E6A04936068CC5A6F68; domain=.bing.com; path=/
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: _EDGE_S=F=1&SID=01BC6F54CDD16E6A04936068CC5A6F68; path=/; httponly; domain=bing.com
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: _EDGE_V=1; path=/; httponly; expires=Thu, 30-Sep-2021 15:12:21 GMT; domain=bing.com
   2020-09-05 23:11:47.397 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: MUID=2AE7B0BA15D560010AA3BF86145E6103; samesite=none; path=/; secure; expires=Thu, 30-Sep-2021 15:12:21 GMT; domain=bing.com
   2020-09-05 23:11:47.398 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Set-Cookie: MUIDB=2AE7B0BA15D560010AA3BF86145E6103; path=/; httponly; expires=Thu, 30-Sep-2021 15:12:21 GMT
   2020-09-05 23:11:47.398 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << Vary: Accept-Encoding
   2020-09-05 23:11:47.398 DEBUG 10485 --- [lication Thread] org.apache.hc.client5.http.headers       : http-outgoing-1 << X-Msedge-Ref: Ref A: E5AD174CC4AA4832BC8F8D750AD30CA9 Ref B: SG2EDGE1120 Ref C: 2020-09-05T15:12:21Z
   ```
   
   can search ` Cookie:` in the log, only with no proxy have `http-outgoing-0 >> Cookie: test=test`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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