-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Bug when reusing CURL handle which was used for FTP download before #12367
Comments
Is this what you guess is happening or have you actually seen any evidence of this? (Because I cannot understand how that would happen) Are you using the easy interface? |
@bagder I am not using the easy interface. I think it doesn't exist in PHP.
It's what I suppose is happening. Please give me some time I will provide an example code within this week. |
So here is the code. I am sorry for the strange URLs I'm using but as soon as I use different URLs everything works fine. The code performs a download of 5 URLs while reusing the CURL handle. The URLs are: https://www.touslesdrivers.com/php/constructeurs/redirection.php?v_code=355 They all redirect (HTTP code 302) to a different URL. The first URL redirects to ftp://ftp.matrox.com/pub/mga/archive/bios/2001/setup208.exe It should be said that You can download the last URL on the command line using However in the PHP script below I get a At the moment I am simply creating a new CURL handle to not experience the bug (which I think it is). Please note it's not neccessary to close the PHP tag. Some people confuse this when they see it the first time. Here it is:
Output on the console:
|
Thanks for the code. I can now reproduce the problem! |
Use the closure handle for disconnecting connection cache entries so that anything that happens during the disconnect is not stored and associated with the 'data' handle which already just finished a transfer and it is important that details from the unrelated disconnect does not taint meta-data in the data handle. Like storing the response code. Reported-by: ohyeaah on github Fixes #12367
I did this
In short
If you reuse a CURL handle in PHP the HTTP code (CURLINFO_HTTP_CODE) may come from a previous FTP request.
Long description
I use CURL to download an FTP file in PHP. Later I reuse the handle to download an HTTPS file from a completely different host.
The HTTPS connection successfully downloads the file but the HTTP return code reported by CURL is 221 which comes from the FTP connection of the previous request.
I traced the FTP connection in Wireshark and it looks like this:
So here again what I do and what probably happens behind the scenes:
I am using PHP 8.2.10-2ubuntu1 and curl_version() reports 8.2.1.
I reported this here because I thought it's probably more a CURL bug than a PHP bug.
I expected the following
At the end I expected CURLINFO_HTTP_CODE to report the HTTP code of the last request.
curl/libcurl version
PHP curl plugin 8.2.1
operating system
KUbuntu 23.10
The text was updated successfully, but these errors were encountered: