New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle the request's path error when using system proxy #254
Conversation
handle the cookie don't send with system proxy
Please create a jira ticket for this issue. Can you write a test that reproduces the problem? |
I suppose a test case involving a proxy might be difficult to setup and reproduce but please at the very least provide a wire / context log of the session exhibiting the problem. |
I don‘t know where is the jira, so I take a example here 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);
Request request = Request.get("http://cn.bing.com");
Executor.newInstance()
.use(cookieStore)
.execute(request);
} if use the system proxy, the debug log like this:
don't use the system proxy, the debug log like this:
they are too long to read, only focus on this line:
this log only appeared in the second debug log |
I simplify this code, and adjust the log level, only log the code like this: 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:
can search |
Superseded by ae67250 |
system: macOS 10.15.6
problem: I take cookieStore to manage my cookies, if I config the system's network, set a proxy, the cookies in the cookieStore won't sent to the website
the reason is the code I changed, before my change, the request's path will change to the all url, actually, the path should be the url's last part expect the host, like 'https://google.com/', the path should be '/', but if there have system proxy, the path will changed to 'http://google.com/', this will make cookie match mistake, so, it won't sent the cookie to the website