Okhttp:在 https 请求中为代理服务器添加未加密的自定义 headers

Okhttp: Adding unencrypted custom headers in for Proxy server on https requests

我们在项目中使用 okhttp v3.8.0。我们必须在 https 请求上专门为代理服务器添加自定义 header。问题是,当我设置“.header("Something", "FRR")”时,header 也会在 https 请求上加密,因此它不会被识别代理服务器。我怎样才能做到这一点?我想在 Initial 方法中发送未加密的 header。 这就是我现在将请求发送到代理服务器的方式:

OK_HTTP_CLIENT = builder
    .connectTimeout(60, TimeUnit.SECONDS)
    .writeTimeout(60, TimeUnit.SECONDS)
    .readTimeout(60, TimeUnit.SECONDS)
    .cookieJar(cookieJar)
    .retryOnConnectionFailure(true)
    .proxy(proxy)
    .proxyAuthenticator(proxyAuthenticatorMainAccount)
    .build();

Request request = new Request.Builder()
    .url(url)
    .header("Something", "FRR")
    .build();

Response response = OK_HTTP_CLIENT.newCall(request).execute();

There is screenshot here, explain what i want to achieve in more details

OkHttp 当前不可能。正在跟踪 here。如果这对您很重要,请说明您的情况,我们会做出相应的回应。