Skip to content

Commit 364d9e1

Browse files
authored
Merge pull request #8041 from kenjis/docs-improve-curlrequest.rst
docs: improve curlrequest.rst
2 parents 21132d4 + 8d903a0 commit 364d9e1

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

user_guide_src/source/libraries/curlrequest.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ cookie
214214
======
215215

216216
This specifies the filename that CURL should use to read cookie values from, and
217-
to save cookie values to. This is done using the CURL_COOKIEJAR and CURL_COOKIEFILE options.
217+
to save cookie values to. This is done using the ``CURL_COOKIEJAR`` and ``CURL_COOKIEFILE`` options.
218218
An example:
219219

220220
.. literalinclude:: curlrequest/021.php
@@ -223,8 +223,10 @@ debug
223223
=====
224224

225225
When ``debug`` is passed and set to ``true``, this will enable additional debugging to echo to STDERR during the
226-
script execution. This is done by passing CURLOPT_VERBOSE and echoing the output. So, when you're running a built-in
227-
server via ``spark serve`` you will see the output in the console. Otherwise, the output will be written to
226+
script execution.
227+
228+
This is done by passing ``CURLOPT_VERBOSE`` and echoing the output. So, when you're running a built-in
229+
server via ``spark serve``, you will see the output in the console. Otherwise, the output will be written to
228230
the server's error log.
229231

230232
.. literalinclude:: curlrequest/034.php
@@ -270,8 +272,11 @@ further headers arrays or calls to ``setHeader()``.
270272
http_errors
271273
===========
272274

273-
By default, CURLRequest will fail if the HTTP code returned is greater than or equal to 400. You can set
274-
``http_errors`` to ``false`` to return the content instead:
275+
By default, CURLRequest will throw ``HTTPException`` if the HTTP code returned is
276+
greater than or equal to 400.
277+
278+
If you want to see the response body, you can set ``http_errors`` to ``false`` to
279+
return the content instead:
275280

276281
.. literalinclude:: curlrequest/026.php
277282

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
$client->request('GET', '/status/500');
4-
// Will fail verbosely
4+
// If the response code is 500, an HTTPException is thrown,
5+
// and a detailed error report is displayed if in development mode.
56

6-
$res = $client->request('GET', '/status/500', ['http_errors' => false]);
7-
echo $res->getStatusCode();
8-
// 500
7+
$response = $client->request('GET', '/status/500', ['http_errors' => false]);
8+
echo $response->getStatusCode(); // 500
9+
echo $response->getBody(); // You can see the response body.

0 commit comments

Comments
 (0)