0

I'm trying to implement async HTTP client with Symfony and amphp/http-client, in symfony docs said thatto enable it for HTTP I need to add http_version: '2.0'option to config and I did it:

framework:
    http_client:
        http_version: '2.0'
        scoped_clients:
            site:
                base_uri: '%env(URL)%'
                headers:
                    x-access-token: '%env(ACCESS_TOKEN)%'

but it's not working and I'm getting error Unrecognized option "http_version" under "framework.http_client". Available options are "default_options", "enabled", "max_host_connections", "mock_response_factory", "scoped_clients".

Any idea what is wrong?? Thanks in advance!

1 Answer 1

1

Looks like the docs might need to be updated a bit. Under a 5.2 app:

bin/console config:dump-reference framework http_client

# HTTP Client configuration
http_client:
    enabled:              true

    # The maximum number of connections to a single host.
    max_host_connections: ~
    default_options:

        # Associative array: header => value(s).
        headers:

            # Prototype
            name:                 ~

        # The maximum number of redirects to follow.
        max_redirects:        ~

        # The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.
        http_version:         ~

So http_version goes under default_options

# config/packages/framework.yaml
framework:
    http_client:
        default_options:
            http_version: '2.0'

bin/console debug:config framework http_client

Current configuration for "framework.http_client"
=================================================

default_options:
    http_version: '2.0'
    headers: {  }
    resolve: {  }
    retry_failed:
        enabled: false
        retry_strategy: null
        http_codes: {  }
        max_retries: 3
        delay: 1000
        multiplier: 2
        max_delay: 0
        jitter: 0.1
enabled: true
scoped_clients: {  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.