-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
CONNECT request is sent with default AHC user-agent, not with the on from RequestBuilder #1730
Comments
I no longer maintain this project (actually looking for new maintainers). |
@insticore coming a bit late for the party, not sure if it's still relevant. I put my hat in for maintaining the repo, so figured it won't hurt to start digging through issues anyways. In the meanwhile - and before I open a PR to fix - let me try and see whether I understand the issue completely: You're seeing a Consider the following, simple usage example taken from one of the examples in this repo: package org.asynchttpclient.example.completable;
import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.Response;
import java.io.IOException;
import static org.asynchttpclient.Dsl.asyncHttpClient;
public class CompletableFutures {
public static void main(String[] args) throws IOException {
try (AsyncHttpClient asyncHttpClient = asyncHttpClient()) {
asyncHttpClient
.prepareGet("http://www.reddit.com/")
.execute()
.toCompletableFuture()
.thenApply(Response::getResponseBody)
.thenAccept(System.out::println)
.join();
}
}
} Note that I swapped Looking at WireShark, I'm seeing the following outbound packet: Which corresponds to what you mentioned. So I can reproduce, but I'm not sure I understand what a desired outcome on your side would be. Can you please be a bit more specific? |
@insticore Just pinging again to see whether you can clarify a bit more. No rush:) |
@TomGranot hi there, thanks a lot for keeping this great project alive! |
@insticore today's a rough one, but will take a look tomorrow evening. If you could ping me if i forget that would be great;) |
@TomGranot hello, just asking if there any news for this issue |
Just to clarify for anybody reading this at a later point in time - this does not affect you if you don't have a proxy server in the way. In @insticore's case it looks like there's an SSL proxy that's sitting between them and the internet, causing the normal flow of HTTPS to be a bit different. Instead of:
We now have:
What @insticore is saying is that in request no. 1 he's seeing the wrong user-agent. What I assume happens is that the interceptor in charge of handling proxy requests (and more specifically, proxy authentication requests) uses the AsyncHttpClient default user-agent. This means that the CONNECT http request sent to the proxy does not "receive" the correct user agent string as you would expect it to. A bit of digging first - I think that the culprit is this piece here, that uses the default user-agent if no user-agent is found. A small modification of the test in here (basically just adding a
As you mentioned the problem is indeed in NettyRequestFactory, and more specifically here - we can simply set the header for
PR: #1742 |
@insticore Merged into master, will be released in 2.12.3. |
The new CONNECT request is made by NettyRequestFactory, where User-Agent is set from AsyncHttpClientConfig, if I correctly understand.
So in result the user-agent differs from the following requests.
Please, is it possible to fix?
This is captured by Wireshark, the first request CONNECT and the headers are:
accept: /.
user-agent: AHC/2.1
The text was updated successfully, but these errors were encountered: