我想将我的HTTP get请求发送给代理,代理将其转发到我真正想要与之交谈的目的地。 我需要像这样发送:
获取https://proxy.com:1234/something DESTINATION_URL:https://destination.com:1234/something"
所以我在DESTINATION_URL告诉我要发送请求的代理。
Currenty我正在使用Java代码向Proxy发送请求以发送请求。这需要更新以包含目标网址
WebResource webResource = proxyClient.resource(ProxyURL);
webResource.type(MediaType.APPLICATION_FORM_URLENCODED);
ClientResponse response = WebResource.accept("application/json").get(ClientResponse.class);
我可以这样做:
ClientResponse response = webResource.header("DESTINATION_URL",<destination_url>).accept("application/json").get(ClientResponse.class);
答案 0 :(得分:0)
您可以使用WebResource.header(String, Object)
。所以在你的情况下:
WebResource webResource = proxyClient.resource(ProxyURL);
webResource.type(MediaType.APPLICATION_FORM_URLENCODED);
webResource.header("DESTINATION_URL", <destination_url>);
ClientResponse response = WebResource.accept("application/json").get(ClientResponse.class);