【发布时间】:2019-02-11 09:04:56
【问题描述】:
我正在尝试使用简单的 HTTP 代理在外部缓存响应。我尝试了以下sn-p:
public static void main(String[] args) {
HttpClient httpClient = HttpClient.builder().options(httpOptions -> {
httpOptions.proxy(proxyOptions -> proxyOptions
.type(Proxy.HTTP)
.address(InetSocketAddress.createUnresolved("localhost", 7000))
);
}).build();
String url = "http://httpbin.org/get";
HttpClientResponse response = httpClient.get(url).block();
System.out.println(response == null ? "null" : response.status().code());
}
...但结果是客户端以CONNECT 命令启动,创建了一个 TCP 隧道。
当我使用curl 时,我会执行以下操作:
curl "http://httpbin.org/get" -x "localhost:7000"
... 它只是向代理发出一个常规的 HTTP 请求。
我的问题:如何使用 Raector-Netty 向代理发出常规(不是基于 CONNECT 的)请求?
【问题讨论】:
标签: http netty http-proxy reactor-netty