@@ -54,13 +54,13 @@ trait MakesHttpRequests
54
54
protected $ encryptCookies = true ;
55
55
56
56
/**
57
- * Indicated whether json- requests should behave like
58
- * the XHR withCredentials-flag was set.
57
+ * Indicated whether JSON requests should be performed "with credentials" (cookies).
58
+ *
59
59
* @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
60
60
*
61
61
* @var bool
62
62
*/
63
- protected $ withCredentials ;
63
+ protected $ withCredentials = false ;
64
64
65
65
/**
66
66
* Define additional headers to be sent with the request.
@@ -240,7 +240,7 @@ public function followingRedirects()
240
240
}
241
241
242
242
/**
243
- * Include cookies and authorization headers in json- requests.
243
+ * Include cookies and authorization headers for JSON requests.
244
244
*
245
245
* @return $this
246
246
*/
@@ -470,8 +470,13 @@ public function json($method, $uri, array $data = [], array $headers = [])
470
470
], $ headers );
471
471
472
472
return $ this ->call (
473
- $ method , $ uri , [], $ this ->prepareCookiesForJsonRequest (),
474
- $ files , $ this ->transformHeadersToServerVars ($ headers ), $ content
473
+ $ method ,
474
+ $ uri ,
475
+ [],
476
+ $ this ->prepareCookiesForJsonRequest (),
477
+ $ files ,
478
+ $ this ->transformHeadersToServerVars ($ headers ),
479
+ $ content
475
480
);
476
481
}
477
482
@@ -600,17 +605,13 @@ protected function prepareCookiesForRequest()
600
605
}
601
606
602
607
/**
603
- * If enabled, add cookies for Json requests.
608
+ * If enabled, add cookies for JSON requests.
604
609
*
605
610
* @return array
606
611
*/
607
612
protected function prepareCookiesForJsonRequest ()
608
613
{
609
- if ($ this ->withCredentials ) {
610
- return $ this ->prepareCookiesForRequest ();
611
- } else {
612
- return [];
613
- }
614
+ return $ this ->withCredentials ? $ this ->prepareCookiesForRequest () : [];
614
615
}
615
616
616
617
/**
0 commit comments