DefaultProxySelector should handle ws/wss protocol like the http/https protocol

XMLWordPrintable

    • Type: CSR
    • Resolution: Withdrawn
    • Priority: P4
    • 27
    • Component/s: core-libs
    • None
    • behavioral
    • low
    • Hide
       Previously ws/wss URIs always returned DIRECT from both
       DefaultProxySelector.select() and ProxySelector.of().select().
       Now they return the configured HTTP/HTTPS proxy. Only callers
       passing ws/wss URIs to these methods are affected. No existing
       correct code depends on ws/wss returning DIRECT, since proxy
       support for these schemes did not exist before this change.
      Show
       Previously ws/wss URIs always returned DIRECT from both  DefaultProxySelector.select() and ProxySelector.of().select().  Now they return the configured HTTP/HTTPS proxy. Only callers  passing ws/wss URIs to these methods are affected. No existing  correct code depends on ws/wss returning DIRECT, since proxy  support for these schemes did not exist before this change.
    • Java API
    • SE

      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:

      1. 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)".

      2. ProxySelector.of(InetSocketAddress) javadoc: Updated to state that WebSocket (ws and wss) URIs are also proxied, as they tunnel over HTTP and HTTPS respectively.

      3. 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".

            Assignee:
            Hyunsu Eun
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: