in src/Traits/EndpointTrait.php [132:163]
protected function createRequest(string $method, string $url, array $headers, $body = null): ServerRequestInterface
{
$requestFactory = Psr17FactoryDiscovery::findServerRequestFactory();
$streamFactory = Psr17FactoryDiscovery::findStreamFactory();
$request = $requestFactory->createServerRequest($method, $url);
// Body request
if (!empty($body)) {
if (!isset($headers['Content-Type'])) {
throw new ContentTypeException(sprintf(
"The Content-Type is missing for %s %s",
$method,
$url
));
}
$content = is_string($body) ? $body : $this->bodySerialize($body, $headers['Content-Type']);
$request = $request->withBody($streamFactory->createStream($content));
}
$client = $this->client ?? $this;
if ($client instanceof ClientInterface && $client->getServerless()) {
$headers[Client::API_VERSION_HEADER] = Client::API_VERSION;
} else {
$headers = $this->buildCompatibilityHeaders($headers);
}
// Headers
foreach ($headers as $name => $value) {
$request = $request->withHeader($name, $value);
}
return $request;
}