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.