I am using okhttp to send some http request from my Android APK. Due to some server-side proxy requirement, I would like the url endpoint to be like: "https://api.example.com", however in the http request, I would like to overwrite the HOST header to be "Host: proxy.example.com". I tried to use something like:
HttpUrl url = new HttpUrl.Builder()
.scheme("https")
.host("api.example.com")
.build();
okhttprequest = new com.squareup.okhttp.Request.Builder()
.url(url)
.method("GET", requestBody)
.header("Host", "proxy.example.com")
.build();
response = mOkHttpClient.newCall(okhttprequest).execute();
However, when I looked into the http request in the network packages, the HOST header was still "api.example.com". Just wonder, any advice that I can actually overwrite the HOST header? Thanks a lot!