From c0073abef7f155477b14f7a4229fc9e20766cd0a Mon Sep 17 00:00:00 2001 From: Fedir Ponikarevych <10107-deimos@users.noreply.drupalcode.org> Date: Thu, 18 Jul 2024 19:50:37 +0000 Subject: [PATCH] Issue #3352503 by deimos, swilmes, heddn: Allow HTTP fetcher to make POST calls --- src/Plugin/migrate_plus/data_fetcher/Http.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Plugin/migrate_plus/data_fetcher/Http.php b/src/Plugin/migrate_plus/data_fetcher/Http.php index d8835a0a..b170cb22 100755 --- a/src/Plugin/migrate_plus/data_fetcher/Http.php +++ b/src/Plugin/migrate_plus/data_fetcher/Http.php @@ -61,6 +61,9 @@ class Http extends DataFetcherPluginBase implements ContainerFactoryPluginInterf // Ensure there is a 'headers' key in the configuration. $configuration += ['headers' => []]; $this->setRequestHeaders($configuration['headers']); + // Set GET request-method by default. + $configuration += ['method' => 'GET']; + $this->configuration['method'] = $configuration['method']; } /** @@ -101,7 +104,8 @@ class Http extends DataFetcherPluginBase implements ContainerFactoryPluginInterf if (!empty($this->configuration['request_options'])) { $options = NestedArray::mergeDeep($options, $this->configuration['request_options']); } - $response = $this->httpClient->get($url, $options); + $method = $this->configuration['method'] ?? 'GET'; + $response = $this->httpClient->request($method, $url, $options); if (empty($response)) { throw new MigrateException('No response at ' . $url . '.'); } -- GitLab