diff --git a/CHANGELOG.md b/CHANGELOG.md index f39b091e..84d17f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### v4.25.2 (2026-08-18) +* * * +### Bug Fixes: +- HTTP methods are now uppercased before a request is constructed, so the SDK no longer emits deprecation notices from `guzzlehttp/psr7` 2.11+ (`Passing a non-uppercase HTTP method is deprecated`) or `guzzlehttp/guzzle` 7.11+. Both libraries preserve method casing in their next major versions, where a lowercase method would have been sent on the wire as-is. + ### v4.25.1 (2026-08-11) * * * ### Bug Fixes: diff --git a/VERSION b/VERSION index 72e19f2f..52665044 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.25.1 +4.25.2 diff --git a/src/HttpClient/GuzzleFactory.php b/src/HttpClient/GuzzleFactory.php index 01895e4c..0febdc6d 100644 --- a/src/HttpClient/GuzzleFactory.php +++ b/src/HttpClient/GuzzleFactory.php @@ -42,7 +42,7 @@ public function create(): \Psr\Http\Client\ClientInterface public function createRequest(ChargebeePayload $chargebeePayload): \Psr\Http\Message\RequestInterface { - $httpMethod = $chargebeePayload->getHttpMethod(); + $httpMethod = strtolower($chargebeePayload->getHttpMethod()); $params = $chargebeePayload->getSerializedParameters(); $headers = $chargebeePayload->getHeaders(); @@ -54,7 +54,7 @@ public function createRequest(ChargebeePayload $chargebeePayload): \Psr\Http\Mes $uri = new Uri($url); $body = null; - if ($chargebeePayload->getHttpMethod() == "get") { + if ($httpMethod == "get") { if (!empty($params)) { $uri = $uri->withQuery($params); } @@ -63,7 +63,7 @@ public function createRequest(ChargebeePayload $chargebeePayload): \Psr\Http\Mes if ($httpMethod == "post") { $body = $params; } - return new \GuzzleHttp\Psr7\Request($httpMethod, $uri, $headers, $body); + return new \GuzzleHttp\Psr7\Request(strtoupper($httpMethod), $uri, $headers, $body); } public static function utf8($value) diff --git a/src/HttpClient/PsrClientAdapter.php b/src/HttpClient/PsrClientAdapter.php index f4fef3b2..dfd11ffc 100644 --- a/src/HttpClient/PsrClientAdapter.php +++ b/src/HttpClient/PsrClientAdapter.php @@ -24,7 +24,7 @@ public function create(): ClientInterface public function createRequest(ChargebeePayload $payload): RequestInterface { - $httpMethod = $payload->getHttpMethod(); + $httpMethod = strtolower($payload->getHttpMethod()); $params = $payload->getSerializedParameters(); $headers = $payload->getHeaders(); diff --git a/src/Version.php b/src/Version.php index aa6a6013..3f65901a 100644 --- a/src/Version.php +++ b/src/Version.php @@ -4,7 +4,7 @@ final class Version { - const VERSION = '4.25.1'; + const VERSION = '4.25.2'; } ?> \ No newline at end of file diff --git a/tests/Network/GuzzleFactoryTest.php b/tests/Network/GuzzleFactoryTest.php new file mode 100644 index 00000000..b80ead6a --- /dev/null +++ b/tests/Network/GuzzleFactoryTest.php @@ -0,0 +1,57 @@ + 'Basic dGVzdA=='], + $env + ); + } + + #[TestDox('createRequest() builds a request with an uppercase HTTP method')] + #[DataProvider('httpMethodProvider')] + public function testCreateRequestUsesUppercaseHttpMethod(string $method, string $expected): void + { + $factory = new GuzzleFactory(10, 30); + + $request = $factory->createRequest($this->makePayload($method, 'limit=10')); + + $this->assertSame($expected, $request->getMethod()); + } + + public static function httpMethodProvider(): array + { + return [ + 'lowercase get' => ['get', 'GET'], + 'lowercase post' => ['post', 'POST'], + 'uppercase get' => ['GET', 'GET'], + 'uppercase post' => ['POST', 'POST'], + ]; + } + + #[TestDox('createRequest() rejects unsupported HTTP methods')] + public function testCreateRequestRejectsUnsupportedMethod(): void + { + $factory = new GuzzleFactory(10, 30); + + $this->expectException(\Exception::class); + $factory->createRequest($this->makePayload('delete')); + } +} diff --git a/tests/Network/MockGuzzleFactory.php b/tests/Network/MockGuzzleFactory.php index a0e503e9..f8ff710c 100644 --- a/tests/Network/MockGuzzleFactory.php +++ b/tests/Network/MockGuzzleFactory.php @@ -132,7 +132,7 @@ public function sendRequest(RequestInterface $request): ResponseInterface public function createRequest(ChargebeePayload $chargebeePayload): RequestInterface { - $httpMethod = $chargebeePayload->getHttpMethod(); + $httpMethod = strtolower($chargebeePayload->getHttpMethod()); $params = $chargebeePayload->getSerializedParameters(); $headers = $chargebeePayload->getHeaders(); @@ -152,7 +152,7 @@ public function createRequest(ChargebeePayload $chargebeePayload): RequestInterf $body = $params; } - return new Request($httpMethod, $uri, $headers, $body); + return new Request(strtoupper($httpMethod), $uri, $headers, $body); } /**