vertx-web icon indicating copy to clipboard operation
vertx-web copied to clipboard

Allow custom Proxy-Authorization header when CONNECT request.

Open calmlaw opened this issue 5 years ago • 2 comments

Describe the feature

Create an HttpRequest and add the Proxy-Authorization header, but the proxy server cannot get the Proxy-Authorization header value when CONNECT request. Because webClient only supports username and password authentication to connect to the proxy server.

webClient.getAbs("https://www.github.com/")
    .putHeader("Proxy-Authorization", "Basic c2lnbj0yMDIwNjI5MjgwODMxODA5RDE0NjUweHh4eHh4eCZvcmRlcm5vPVpGMjAxNzIzMDE1MXh4eHh4eHgmdGltZXN0YW1wPTE0ODc3NTM1MjE=")
    .send(ar -> {
        if (ar.succeeded()) {
            System.out.println(ar.result().bodyAsString());
        } else {
            ar.cause().printStackTrace();
        }
    });

calmlaw avatar Nov 17 '20 11:11 calmlaw

@aomsweet the current API, allows something like:

httpRequest.authentication(new UsernamePasswordCredentials("username", "password"));

I think we should have a second method:

httpRequest.proxyAuthentication(new UsernamePasswordCredentials("username", "password"));

That uses: Proxy-Authorization as the header instead of Authorization

Using the credentials object means it will cover the Basic, 'Digest, Bearer` out of the box and with custom implementation, also the remaining IANA schemes.

The Fix is simple (add the method to the interface + implement like the existing one and switching the header name).

Are you will to make a pull request?

pmlopes avatar Nov 18 '20 09:11 pmlopes

@pmlopes

Thanks for your suggestions and help, I will try to complete this feature and make a pull request.

calmlaw avatar Nov 18 '20 09:11 calmlaw