Skip to content

Commit c7693fc

Browse files
fix: missing headers and body in http request with psr17
ref: joelbutcher#7
1 parent f66c5cd commit c7693fc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Client.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,12 @@ public function sendRequest(Request $request)
188188

189189
list($url, $method, $headers, $body) = $this->prepareRequestMessage($request);
190190

191-
$psr7Response = $this->httpClient->sendRequest(
192-
Psr17FactoryDiscovery::findRequestFactory()->createRequest($method, $url, $headers, $body)
193-
);
191+
$psr7Request = Psr17FactoryDiscovery::findRequestFactory()->createRequest($method, $url);
192+
foreach ($headers as $k => $v) {
193+
$psr7Request = $psr7Request->withHeader($k, $v);
194+
}
195+
$psr7Request = $psr7Request->withBody(Psr17FactoryDiscovery::findStreamFactory()->createStream($body));
196+
$psr7Response = $this->httpClient->sendRequest($psr7Request);
194197

195198
static::$requestCount++;
196199

0 commit comments

Comments
 (0)