Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17234

Reactive Web Client - Using HTTP proxy implicitly creates a tunnel

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Reactive, Web:Client
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Expected behavior

      When I run a local proxy (port 7000), and use curl, the command looks like this:

      curl "http://httpbin.org/status/200" -x localhost:7000

      What happens, and this is the expected behavior, is that curl establishes a TCP connection to localhost:7000, and runs the HTTP request against the local proxy, rather than the target (httpbin).

      Actual behavior

      If I use the following code:

      public static void main(String[] args) {
        ReactorClientHttpConnector connector = new ReactorClientHttpConnector(options -> {
          options.httpProxy(addressSpec -> addressSpec.address(InetSocketAddress.createUnresolved("localhost", 7000)));
        });
        WebClient webClient = WebClient.builder()
            .clientConnector(connector)
            .build();
      
        String url = "http://httpbin.org/status/200";
        Mono<ClientResponse> exchange = webClient.get().uri(URI.create(url)).exchange();
        ClientResponse response = exchange.block();
        System.out.println(response.statusCode().value());
      }

       

       

      then the http client would first execute a CONNECT command (method) against the local proxy, and then would execute the original HTTP request (GET) inside the TCP level channel/tunnel it created from the executed CONNECT method.
      I would expect that the default behavior when using a HTTP proxy would be the same as the one provided by curl, demonstrated above.

      Spring Boot Version:
      2.0.4.RELEASE
      OS:
      Mac 10.13.6

        Attachments

          Activity

            People

            Assignee:
            bclozel Brian Clozel
            Reporter:
            ronklein Ron Klein
            Last updater:
            Spring Issuemaster
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 36 weeks, 5 days ago