Skip to content

Support pre-emptive Proxy Authentication for plaintext (http) requests #9239

@yu1147

Description

@yu1147

I want to use okhttp to implement --proxy-user so that the header includes Proxy-Authorization. I found that authenticate can achieve this, and it indeed works under HTTPS. However, once I send an HTTP request, like:

Request request = new Request.Builder()
.url("http://httpbin.org/headers") // This service returns the received request headers
.header("saaa", "bbb")
.build();
This header is not automatically added. I looked at the underlying source code and found that createTunnelRequest creates a fakeAuthChallengeResponse, which explains why it appears to be mandatory.

My first question is: Why isn't HTTP designed in the same way?
My second question is: After returning 407, HTTP also includes Proxy-Authorization. Is this interaction defined by a standard?

Thank you for your answer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug in existing code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions