Proposal:
The HttpClientDiscovery and MessageFactoryDiscovery classes have been deprecated and Psr18ClientDiscovery and Psr17FactoryDiscovery are recommended.
The current implementation of the PhpHttp class may also contain errors, as not all message factories support passing $headers and $content when creating a request. Specifically, when using "GuzzleHttp\Psr7\HttpFactory," we won't be able to pass these parameters. Here is the code from "GuzzleHttp\Psr7\HttpFactory"
public function createRequest(string $method, $uri): RequestInterface
{
return new Request($method, $uri);
}
I suggest adding additional validation and recording of these parameters when creating a Request. For example:
$message = $this->messageFactory->createRequest($method, $url, $headers, $content);
if (!$message->hasHeader('Content-Type')) {
foreach ($headers as $key => $value) {
$message = $message->withAddedHeader($key, $value);
}
}
if (!empty($content) && empty($message->getBody()->getContents())) {
$message = $message->withBody($this->messageFactory->createStream($content));
}
#259
Checklist:
To be completed by the assignee. Check off tasks that have been completed or are not applicable.
Details
Proposal:
The HttpClientDiscovery and MessageFactoryDiscovery classes have been deprecated and Psr18ClientDiscovery and Psr17FactoryDiscovery are recommended.
The current implementation of the PhpHttp class may also contain errors, as not all message factories support passing $headers and $content when creating a request. Specifically, when using "GuzzleHttp\Psr7\HttpFactory," we won't be able to pass these parameters. Here is the code from "GuzzleHttp\Psr7\HttpFactory"
I suggest adding additional validation and recording of these parameters when creating a Request. For example:
#259
Checklist:
To be completed by the assignee. Check off tasks that have been completed or are not applicable.
Details