Problem/Motivation

I would like to use the Drupal's proxy configuration when I'm calling a service through HTTP_CLIENT_MANAGER.

Steps to reproduce

Create a custom module using HTTP_CLIENT_MANAGER. (ex: test_proxy)

  • Define the proxy's settings on your Drupal's settings file.
    $settings['http_client_config']['proxy']['http'] = 'https://<user>:<password>@<location>:<port>';
    $settings['http_client_config']['proxy']['https'] = 'https://<user>:<password>@<location>:<port>';
    $settings['http_client_config']['proxy']['no'] = ['127.0.0.1', 'localhost'];
    
  • Create modules/custom/test_proxy/test_proxy.http_services_api.yml
    beh_services.httpbin:
      title: "[Services] Httpbin"
      api_path: "/src/api/httpbin.yml"
      config:
        base_uri: "https://httpbin.org"
    
  • Create modules/custom/test_proxy/src/api/httpbin.yml
    name: "[Services] Httpbin"
    apiVersion: "1.0"
    description: "Client wrapper Httpbin API."
    imports:
      - "resources/httpbin/content.yml"
    
  • Create modules/custom/test_proxy/src/api/resources/httpbin/content.yml
    operations:
    
      GetContent:
        httpMethod: "GET"
        uri: "/get"
        summary: "Gets the origin."
        responseModel: "ContentData"
    
    models:
    
      ContentData:
        type: "object"
        location: "json"
        properties:
          args:
            type: "json"
            location: "json"
          headers:
            type: "json"
            location: "json"
          origin:
            type: "string"
            location: "json"
          url:
            type: "string"
            location: "json"
    

When I'm testing the service, through the UI, the Origin in the httpbin response is my network IP. It should be the proxy's.

Proposed resolution

TBD.

Comments

fabrer created an issue.

fabrer’s picture

Update: I revert to use Guzzle calls instead of http_client_manager. However I'm still interested in any answer/help for my next projects.

Regards,