Summary
DefaultProxySelector and ProxySelector.of() now treat ws and wss URI
schemes the same as http and https for proxy selection.
Problem
DefaultProxySelector.select() does not recognize ws or wss URI schemes. When proxy properties like http.proxyHost are configured, select() still returns DIRECT for ws/wss URIs. Since WebSocket connections tunnel over HTTP/HTTPS (RFC 6455), they should use the same proxy settings.
Solution
Normalize ws to http and wss to https at the top of DefaultProxySelector.select(), before the property lookup in the props array. The same fix is applied to StaticProxySelector returned by ProxySelector.of(). This approach is consistent with the existing normalization in OpeningHandshake.createRequestURI().
Specification
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29882&range=00
Full diff: https://git.openjdk.org/jdk/pull/29882.diff
Three documentation surfaces are updated:
-
ProxySelector.select(URI) javadoc: The URI format list now includes "ws URI for WebSocket connections (treated as http)" and "wss URI for secure WebSocket connections (treated as https)".
-
ProxySelector.of(InetSocketAddress) javadoc: Updated to state that WebSocket (ws and wss) URIs are also proxied, as they tunnel over HTTP and HTTPS respectively.
-
net-properties.html: HTTP proxy section now reads "for URIs with the http:// or ws:// scheme". HTTPS proxy section now reads "for URIs with the https:// or wss:// scheme".
- csr of
-
JDK-8368157 DefaultProxySelector should handle ws/wss protocol like the http/https protocol
-
- Closed
-