[php-src] Issue #11090: curl - fail-with-body support
| From: | rbro | Date: | Sun, 16 Apr 2023 21:35:22 +0000 |
| Subject: | [php-src] Issue #11090: curl - fail-with-body support | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244214@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11090
Author: rbro
### Description
In cURL 7.76.0, a new option --fail-with-body was added:
https://daniel.haxx.se/blog/2021/02/11/curl-fail-with-body
Would it be possible to implement similar functionality in PHP's curl library?
I posted the below in Stack Overflow in 2021:
https://stackoverflow.com/questions/68246166/how-to-retrieve-curl-response-on-error-in-php
As I wrote in the post, I'm looking to:
- on success, have the http response pass directly to the user's browser
- but on error such as a http 500 error, get the http response body into a variable in PHP
I don't want to use CURLOPT_RETURNTRANSFER because on success, the PDF file returned is large
and it would be inefficient to first save the file to a PHP string or a temp file, only to just echo
it to the user's browser.
What I'm looking for is an option called CURLOPT_RETURNTRANSFERONERROR, where the response data
is only returned on a http error.
Thank you for your help.
Ryan