Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.6.18 — Update released for Drupal core (10.6.18)! Release: Drupal 11.4.8 — Update released for Drupal core (11.4.8)! Release: Cms 2.2.0 — Update released for Drupal core (2.2.0)! Release: Varbase Workflow 2.2.2 — Minor update available for module varbase_workflow (2.2.2). Release: Varbase Workflow 3.1.4 — Minor update available for module varbase_workflow (3.1.4). Release: Varbase SEO 9.2.4 — Minor update available for module varbase_seo (9.2.4). Release: Synapse Theme 2.1.14 — Minor update available for module syntheme (2.1.14). Release: Varbase Events Base recipe 1.0.2 — Minor update available for module varbase_events_base (1.0.2). Module Revived: CSS Variables Customizer 1.0.0 — Module css_variables_customizer updated after 12 months of inactivity (1.0.0). Security Coverage: CKEditor5 Pullquote — Module ckeditor5_pullquote now has official Drupal security advisory coverage.

This module allows to set the options applied to outgoing Drupal requests based on the URI of the request.

Details

By default, Drupal uses Guzzle's HTTP Client for the outgoing HTTP requests (for example, when Drupal needs to fetch data from a webservice). This HTTP Client can be configured using $settings variable like this:

$settings['http_client_config']['timeout'] = 60;

That configuration would be applied to any outgoing connection using standard Drupal HTTP request mechanism. However, sometimes different configurations are needed for different outgoing connections. HTTP Client Options per URI solve this problem allowing to define a set of options for different URIs.

Use cases

This module is needed when Drupal needs to connect to different remote services with different connections options instead of using the same configuration for all outgoing connections.

For example, for performance reasons outgoing connection timeouts must be as low as possible so that a slow remote web server doesn't cause Drupal requests to take longer than recommended. However, some services are slower than others. Using the same configuration for all services means using the highest timeout that fits the slower service for all connections. Using this module a custom timeout can be configured for the slower services, using a low timeout for the other services.

How it works

Guzzle uses the concept of Middleware to alter the requests and responses. This module replaces the standard Drupal http_client_factory service with a customized service that allows client options per URI. To do this the module adds a custom Guzzle's Middleware that checks $settings['http_client_options_per_uri_config'] looking for custom options on outgoing HTTP connections.

Usage

The module has no UI. To add a custom HTTP client options use the $settings['http_client_options_per_uri_config'] setting.

$settings['http_client_options_per_uri_config'] is an array. Each key is an identifier for the custom options. Each custom option have the following entries:

- regexp: a regular expression to determine to which outgoing connections the options will be applied. If the regexp matches, the options are applied. If more than one regexp matches only the last one is applied.

- options: an array with standard Guzzle options that will be applied to the outgoing connection.

Examples

Customize PayPal timeout

$settings['http_client_options_per_uri_config']['paypal'] = [
  'regexp' => '/^http(?:s)?:\/\/api\.(?:sandbox\.)?paypal\.com.*$/i',
  'options' => [
    'timeout' => 10,
    'connect_timeout' => 10,
  ],
];

Customize Mandrill timeout

$settings['http_client_options_per_uri_config']['mandrill'] = [
  'regexp' => '/^http(?:s)?:\/\/mandrillapp\.com\/api\/.*$/i',
  'options' => [
    'timeout' => 10,
    'connect_timeout' => 10,
  ],
];

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Sep 2026
Latest release
4 hours ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
2.0.0-beta1 Pre-release 10–11 Sep 26, 2026
2.x-dev Dev 10–11 Sep 26, 2026