Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit a48c8e2

Browse files
committed
:octocat: POST/header fix
1 parent cc7fc1a commit a48c8e2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Core/OAuthProvider.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ public function request(string $path, array $params = null, string $method = nul
290290
$request = $this->requestFactory
291291
->createRequest($method ?? 'GET', Psr7\merge_query($this->apiURL.$path, $params ?? []));
292292

293+
foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
294+
$request = $request->withAddedHeader($header, $value);
295+
}
296+
293297
if(is_array($body) && $request->hasHeader('content-type')){
294298
$contentType = strtolower($request->getHeaderLine('content-type'));
295299

@@ -303,12 +307,11 @@ public function request(string $path, array $params = null, string $method = nul
303307

304308
}
305309

306-
foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
307-
$request = $request->withAddedHeader($header, $value);
308-
}
309-
310310
if($body instanceof StreamInterface){
311-
$request = $request->withBody($body);
311+
$request = $request
312+
->withBody($body)
313+
->withHeader('Content-length', $body->getSize())
314+
;
312315
}
313316

314317
return $this->sendRequest($request);

0 commit comments

Comments
 (0)