HTTP Client Config
Last updated
Last updated
Like headers and query parameters, HTTP config can be added by using the config()
method on either the connector or the request. When you add config to a connector instance, every request sent through that connector will merge those configuration options with the request. When you add config to a request instance, it will just be added to that one request instance.
Saloon's default sender is the GuzzleSender. By default, the config options are added to the guzzle request. You can use any of the options Guzzle provide in the Saloon's config.
You may configure the default HTTP config on the connector or request using the protected defaultConfig
method.
You may also use properties in requests to populate HTTP config, for example - specifying an exact timeout on a per-request basis.
Saloon also offers a handy config API to manage them easily after a request instance has been created. Use the config()
method on your request to manage them. HTTP config added to the request is prioritised more than the connector's config. This is useful for changing them before a request is sent.
When you have default HTTP config on a connector, they won't be visible to the request instance as they are merged later in the request lifecycle. Still, request HTTP config will have a higher priority than connector config.
Overwrite the config on the request with a new array.
Merge arrays of config.
Remove a given config option by its key.
Get a givenconfig option by its key or return the default.
Retrieve all config options as an array.
Check if the config object is empty.