Skip to content

Update PhpHttp Transport #258

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.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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