File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
user_guide_src/source/libraries Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -272,8 +272,11 @@ further headers arrays or calls to ``setHeader()``.
272272http_errors
273273===========
274274
275- By default, CURLRequest will fail if the HTTP code returned is greater than or equal to 400. You can set
276- ``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:
277280
278281.. literalinclude :: curlrequest/026.php
279282
Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments