Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/src/Upload/MultipartUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function prepareRequest()

$size = $multipartStream->getSize();
if ($size !== null) {
$headers['Content-Length'] = $size;
$headers['Content-Length'] = (string) $size;
}

$customHeaders = $this->requestOptions['restOptions']['headers'] ?? [];
Expand Down
4 changes: 2 additions & 2 deletions Core/src/Upload/ResumableUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function upload()
$rangeEnd = $rangeStart + ($currStreamLimitSize - 1);

$headers = $this->headers + [
'Content-Length' => $currStreamLimitSize,
'Content-Length' => (string) $currStreamLimitSize,
'Content-Type' => $this->contentType,
'Content-Range' => "bytes $rangeStart-$rangeEnd/$size",
];
Expand Down Expand Up @@ -245,7 +245,7 @@ protected function createResumeUri()
{
$headers = $this->headers + [
'X-Upload-Content-Type' => $this->contentType,
'X-Upload-Content-Length' => $this->data->getSize(),
'X-Upload-Content-Length' => (string) $this->data->getSize(),
'Content-Type' => 'application/json'
];

Expand Down
2 changes: 1 addition & 1 deletion Core/src/Upload/SignedUrlUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function createResumeUri()
{
$headers = $this->headers + [
'Content-Type' => $this->contentType,
'Content-Length' => 0,
'Content-Length' => '0',
'x-goog-resumable' => 'start'
];

Expand Down
2 changes: 1 addition & 1 deletion Core/src/Upload/StreamableUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function upload($writeSize = null)

// do the streaming write
$headers = [
'Content-Length' => $writeSize,
'Content-Length' => (string) $writeSize,
'Content-Type' => $this->contentType,
'Content-Range' => "bytes {$this->rangeStart}-$rangeEnd/*"
];
Expand Down
5 changes: 5 additions & 0 deletions Core/tests/Unit/Upload/MultipartUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public function testStreamWithoutSizeDoesNotReceiveContentLengthHeader($stream,
Argument::that(
function (RequestInterface $request) use ($shouldContentLengthExist) {
$this->assertEquals($request->hasHeader('Content-Length'), $shouldContentLengthExist);

foreach ($request->getHeader('Content-Length') as $value) {
$this->assertIsString($value);
}

return true;
}
),
Expand Down
5 changes: 4 additions & 1 deletion Core/tests/Unit/Upload/ResumableUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public function testGetResumeUri()
$response = new Response(200, ['Location' => $resumeUri]);

$this->requestWrapper->send(
Argument::type(RequestInterface::class),
Argument::that(function (RequestInterface $request) {
return $request->getHeader('X-Upload-Content-Length') === ['4'];
}),
Argument::type('array')
)->willReturn($response);

Expand Down Expand Up @@ -282,6 +284,7 @@ public function testUploadDoesNotSendGoogHashOnIntermediateChunk()
$this->requestWrapper->send(
Argument::that(function (RequestInterface $request) {
return $request->getHeaderLine('Content-Range') === 'bytes 0-1/4'
&& $request->getHeader('Content-Length') === ['2']
&& !$request->hasHeader('X-Goog-Hash');
}),
Argument::type('array')
Expand Down
2 changes: 1 addition & 1 deletion Core/tests/Unit/Upload/SignedUrlUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testGetResumeUri()
return false;
}

if ($arg->getHeaderLine('Content-Length') != 0) {
if ($arg->getHeader('Content-Length') !== ['0']) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/tests/Unit/Upload/StreamableUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function testLastChunkSendsCorrectHeaders()

$this->requestWrapper->send(
Argument::that(function ($request) {
return $request->getHeaderLine('Content-Length') == '10';
return $request->getHeader('Content-Length') === ['10'];
}),
Argument::type('array')
)->willReturn($response)->shouldBeCalled();
Expand Down
Loading