-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Invalid response header" with CURLOPT_FILE
curl option
#65
Comments
Thanks for the report, I wasn't aware of this flag! Fixed in 1.5.0 :) |
Hey, thanks for having been that fast. The following code (with working links so that you can copy/paste to try it) $curl = new cURL();
$file = fopen(realpath('.') . '/php-8.0.7.tar.gz', 'w');
$request = $curl
->newRequest('get', 'https://www.php.net/distributions/php-8.0.7.tar.gz')
->setOption(CURLOPT_FILE, $file)
->send(); Keeps throwing this exception:
The file is properly downloaded, but the script fails because being unable to get the response HTTP status code. |
The headers are part of the file that's downloaded, but there's something else going on here. I wrote a working test case but your example does indeed fail. I'll investigate further, it might be the combination of |
Seems like this has something to do with how the file handle is opened. If you open it in write-only mode, |
When using
CURLOPT_FILE
curl option to write huge contents into a file directly, theResponse
constructor tries to retrieve status code (which is not readable is this particular case) and leads to theInvalid response header
exception.The text was updated successfully, but these errors were encountered: