Skip to content

Update PhpHttp Transport #258

@DimmmCom

Description

@DimmmCom

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.

  • Implementation completed
  • Tests developed
  • Documentation updated
  • Documentation reviewed
  • OpenAPI YAML updated and issue created to rebuild clients

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions