Skip to content

Commit 3d9a7b5

Browse files
author
Maciej Tarnowski
committed
Prevent cURL from adding Expect: 100-continue header to large requests
1 parent 6d50d28 commit 3d9a7b5

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/Handler/CurlRequestHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ protected function setUpCurl(RequestInterface $request, $curlHandle)
168168
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, (string) $request->getBody());
169169
}
170170

171+
if (!$request->hasHeader('expect') && $request->getBody()->getSize() > 0) {
172+
// prevent cURL from adding `Expect: 100-continue` automatically
173+
$headers['Expect'] = '';
174+
}
175+
171176
if ($request->getMethod() === self::METHOD_DELETE) {
172177
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, self::METHOD_DELETE);
173178
if ($request->getBody()->getSize() > 0) {

src/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
*/
99
class Version
1010
{
11-
const VERSION = '1.0.0';
11+
const VERSION = '1.1.0';
1212
}

tests/Unit/Exception/ExceptionFactoryTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ class ExceptionFactoryTest extends \PHPUnit_Framework_TestCase
2929
public function shouldInstantiateCorrectExceptionClass($code, $expectedClass, $expectedMessage)
3030
{
3131
$request = new Request('get', 'http://url.com', []);
32-
$response = new Response($code, []);
32+
if ($code < 100 || $code >= 600) {
33+
$response = null;
34+
} else {
35+
$response = new Response($code, []);
36+
}
3337
$message = 'error message';
3438
$handlerInfo = ['foo' => 'bar'];
3539
$exception = ExceptionFactory::exceptionFrom($code, $request, $message, $handlerInfo, '10', $response);

tests/Unit/Operation/CommandOperationTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@ public function shouldThrowInvalidCommandDataExceptionDuringSetWithInvalidField(
4242
$this->systemUnderTest->set('fromField', uniqid('fromField', true));
4343
}
4444

45-
/**
46-
* @test
47-
* @expectedException \Getresponse\Sdk\Client\Exception\InvalidCommandDataException
48-
* @expectedExceptionMessage Command Getresponse\Sdk\Client\Test\Unit\Operation\CommandOperationImplementation is missing required fields: email, campaign
49-
*/
50-
public function shouldThrowInvalidCommandDataExceptionDuringGetBodyIfNotAllRequiredFieldsAreSet()
51-
{
52-
self::markTestSkipped('Do not check fields requirement');
53-
$this->systemUnderTest->getBody();
54-
}
55-
5645
/**
5746
* @test
5847
* @expectedException \Getresponse\Sdk\Client\Exception\InvalidCommandDataException

0 commit comments

Comments
 (0)