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

Commit

Permalink
:octocat: POST/header fix
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Mar 8, 2019
1 parent cc7fc1a commit a48c8e2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Core/OAuthProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ public function request(string $path, array $params = null, string $method = nul
$request = $this->requestFactory
->createRequest($method ?? 'GET', Psr7\merge_query($this->apiURL.$path, $params ?? []));

foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
$request = $request->withAddedHeader($header, $value);
}

if(is_array($body) && $request->hasHeader('content-type')){
$contentType = strtolower($request->getHeaderLine('content-type'));

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

}

foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
$request = $request->withAddedHeader($header, $value);
}

if($body instanceof StreamInterface){
$request = $request->withBody($body);
$request = $request
->withBody($body)
->withHeader('Content-length', $body->getSize())
;
}

return $this->sendRequest($request);
Expand Down

0 comments on commit a48c8e2

Please sign in to comment.