diff options
Diffstat (limited to 'src/PSR7Client.php')
-rw-r--r-- | src/PSR7Client.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/PSR7Client.php b/src/PSR7Client.php index 111ab6ce..b12159a5 100644 --- a/src/PSR7Client.php +++ b/src/PSR7Client.php @@ -93,7 +93,6 @@ class PSR7Client $request = $request ->withCookieParams($ctx['cookies']) - ->withProtocolVersion($ctx['protocol']) ->withQueryParams($query) ->withUploadedFiles($this->wrapUploads($ctx['uploads'])); @@ -105,17 +104,15 @@ class PSR7Client $request = $request->withHeader($name, $value); } - if ($body !== null) { + if ($ctx['parsed']) { + $request = $request->withParsedBody(json_decode($body, true)); + } else if ($body !== null) { $bodyStream = $this->streamFactory->createStream($body); $bodyStream->write($body); $request = $request->withBody($bodyStream); } - if ($ctx['parsed']) { - $request = $request->withParsedBody(json_decode($body, true)); - } - return $request; } @@ -175,8 +172,12 @@ class PSR7Client continue; } + $stream = UPLOAD_ERR_OK === $f['error'] ? + $this->streamFactory->createStreamFromFile($f['tmpName']) : + $this->streamFactory->createStream(); + $result[$index] = $this->uploadsFactory->createUploadedFile( - $this->streamFactory->createStreamFromFile($f['tmpName']), + $stream, $f['size'], $f['error'], $f['name'], |