diff --git a/composer.json b/composer.json index 52920554dd47..2bf7e5910c65 100644 --- a/composer.json +++ b/composer.json @@ -79,7 +79,7 @@ "aws/aws-sdk-php": "^3.0", "doctrine/dbal": "^2.6", "filp/whoops": "^2.4", - "guzzlehttp/guzzle": "^6.3|^7.0", + "guzzlehttp/guzzle": "^6.3.1|^7.0", "league/flysystem-cached-adapter": "^1.0", "mockery/mockery": "^1.3.1", "moontoast/math": "^1.1", @@ -124,7 +124,7 @@ "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).", "filp/whoops": "Required for friendly error pages in development (^2.4).", "fzaninotto/faker": "Required to use the eloquent factory builder (^1.9.1).", - "guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.3|^7.0).", + "guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.3.1|^7.0).", "laravel/tinker": "Required to use the tinker console command (^2.0).", "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).", "league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).", diff --git a/src/Illuminate/Console/composer.json b/src/Illuminate/Console/composer.json index 4ea95ddf29b5..181dc9ea44b9 100755 --- a/src/Illuminate/Console/composer.json +++ b/src/Illuminate/Console/composer.json @@ -32,7 +32,7 @@ }, "suggest": { "dragonmantank/cron-expression": "Required to use scheduling component (^2.0).", - "guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.3|^7.0).", + "guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.3.1|^7.0).", "illuminate/filesystem": "Required to use the generator command (^7.0)" }, "config": { diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index 3b590d6251fa..6e435285034d 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -3,6 +3,7 @@ namespace Illuminate\Http\Client; use GuzzleHttp\Client; +use GuzzleHttp\Cookie\CookieJarInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\HandlerStack; use Illuminate\Support\Traits\Macroable; @@ -284,10 +285,10 @@ public function withToken($token, $type = 'Bearer') /** * Specify the cookies that should be included with the request. * - * @param array $cookies + * @param \GuzzleHttp\Cookie\CookieJarInterface $cookies * @return $this */ - public function withCookies(array $cookies) + public function withCookies(CookieJarInterface $cookies) { return tap($this, function ($request) use ($cookies) { return $this->options = array_merge_recursive($this->options, [ diff --git a/src/Illuminate/Http/composer.json b/src/Illuminate/Http/composer.json index 68aaa6b8319b..6f6184bd0e4e 100755 --- a/src/Illuminate/Http/composer.json +++ b/src/Illuminate/Http/composer.json @@ -28,7 +28,8 @@ } }, "suggest": { - "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image()." + "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().", + "guzzlehttp/guzzle": "Required to use the HTTP Client (^6.3.1|^7.0)." }, "extra": { "branch-alias": { diff --git a/src/Illuminate/Mail/composer.json b/src/Illuminate/Mail/composer.json index fbefed3fb50d..706a8c039bcf 100755 --- a/src/Illuminate/Mail/composer.json +++ b/src/Illuminate/Mail/composer.json @@ -36,7 +36,7 @@ }, "suggest": { "aws/aws-sdk-php": "Required to use the SES mail driver (^3.0).", - "guzzlehttp/guzzle": "Required to use the Mailgun mail driver (^6.3|^7.0).", + "guzzlehttp/guzzle": "Required to use the Mailgun mail driver (^6.3.1|^7.0).", "wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)." }, "config": { diff --git a/src/Illuminate/Support/Facades/Http.php b/src/Illuminate/Support/Facades/Http.php index 5a8e4eafc203..1f6a05943106 100644 --- a/src/Illuminate/Support/Facades/Http.php +++ b/src/Illuminate/Support/Facades/Http.php @@ -2,6 +2,7 @@ namespace Illuminate\Support\Facades; +use GuzzleHttp\Cookie\CookieJarInterface; use Illuminate\Http\Client\Factory; /** @@ -18,7 +19,7 @@ * @method static \Illuminate\Http\Client\PendingRequest withBasicAuth(string $username, string $password) * @method static \Illuminate\Http\Client\PendingRequest withDigestAuth(string $username, string $password) * @method static \Illuminate\Http\Client\PendingRequest withToken(string $token, string $type = 'Bearer') - * @method static \Illuminate\Http\Client\PendingRequest withCookies(array $cookies) + * @method static \Illuminate\Http\Client\PendingRequest withCookies(CookieJarInterface $cookies) * @method static \Illuminate\Http\Client\PendingRequest withoutRedirecting() * @method static \Illuminate\Http\Client\PendingRequest withoutVerifying() * @method static \Illuminate\Http\Client\PendingRequest timeout(int $seconds) diff --git a/tests/Http/HttpClientTest.php b/tests/Http/HttpClientTest.php index 051132ca5bd5..24ed41e8e8a1 100644 --- a/tests/Http/HttpClientTest.php +++ b/tests/Http/HttpClientTest.php @@ -2,6 +2,8 @@ namespace Illuminate\Tests\Http; +use GuzzleHttp\Cookie\CookieJar; +use GuzzleHttp\Cookie\CookieJarInterface; use Illuminate\Http\Client\Factory; use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\Request; @@ -193,4 +195,22 @@ public function testFakeSequence() $this->assertSame(201, $this->factory->get('https://example.com')->status()); $this->assertSame(301, $this->factory->get('https://example.com')->status()); } + + public function testWithCookies() + { + $this->factory->fakeSequence()->pushStatus(200); + + $response = $this->factory->withCookies( + CookieJar::fromArray(['foo' => 'bar'], 'https://laravel.com') + )->get('https://laravel.com'); + + $this->assertCount(1, $response->cookies()->toArray()); + + /** @var CookieJarInterface $responseCookies */ + $responseCookie = $response->cookies()->toArray()[0]; + + $this->assertSame('foo', $responseCookie['Name']); + $this->assertSame('bar', $responseCookie['Value']); + $this->assertSame('https://laravel.com', $responseCookie['Domain']); + } }