1313namespace chillerlan \HTTP \Psr18 ;
1414
1515use chillerlan \HTTP \HTTPOptions ;
16+ use chillerlan \HTTP \Psr17 \{RequestFactory , ResponseFactory };
1617use chillerlan \HTTP \Psr7 \Request ;
17- use chillerlan \HTTP \Psr17 \ResponseFactory ;
1818use chillerlan \Settings \SettingsContainerInterface ;
19- use Psr \Http \Message \{ResponseFactoryInterface , ResponseInterface };
19+ use Psr \Http \Message \{RequestFactoryInterface , ResponseFactoryInterface , ResponseInterface };
2020use Psr \Log \{LoggerAwareInterface , LoggerAwareTrait , LoggerInterface , NullLogger };
2121
2222use function chillerlan \HTTP \Psr7 \{merge_query , normalize_request_headers };
@@ -44,18 +44,21 @@ abstract class HTTPClientAbstract implements HTTPClientInterface, LoggerAwareInt
4444 protected $ responseFactory ;
4545
4646 /**
47- * CurlClient constructor.
47+ * HTTPClientAbstract constructor.
4848 *
4949 * @param \chillerlan\Settings\SettingsContainerInterface|null $options
50+ * @param \Psr\Http\Message\RequestFactoryInterface|null $requestFactory
5051 * @param \Psr\Http\Message\ResponseFactoryInterface|null $responseFactory
5152 * @param \Psr\Log\LoggerInterface|null $logger
5253 */
5354 public function __construct (
5455 SettingsContainerInterface $ options = null ,
56+ RequestFactoryInterface $ requestFactory = null ,
5557 ResponseFactoryInterface $ responseFactory = null ,
5658 LoggerInterface $ logger = null
5759 ){
5860 $ this ->options = $ options ?? new HTTPOptions ;
61+ $ this ->requestFactory = $ requestFactory ?? new RequestFactory ;
5962 $ this ->responseFactory = $ responseFactory ?? new ResponseFactory ;
6063 $ this ->logger = $ logger ?? new NullLogger ;
6164 }
@@ -74,7 +77,7 @@ public function __construct(
7477 public function request (string $ uri , string $ method = null , array $ query = null , $ body = null , array $ headers = null ):ResponseInterface {
7578 $ method = strtoupper ($ method ?? 'GET ' );
7679 $ headers = normalize_request_headers ($ headers );
77- $ request = new Request ($ method , merge_query ($ uri , $ query ?? []));
80+ $ request = $ this -> requestFactory -> createRequest ($ method , merge_query ($ uri , $ query ?? []));
7881
7982 if (in_array ($ method , ['DELETE ' , 'PATCH ' , 'POST ' , 'PUT ' ], true ) && $ body !== null ){
8083
0 commit comments