-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Guzzle adds an empty header on multipart POST request containing an animated GIF #2905
Comments
Tagging @Zegnat (nyholm/psr7 maintainer) as they wanted to keep an eye on this issue |
It looks like the Accept header is being turned into whitespace for some reason. Here’s apache_request_headers() for a valid upload via the curl command line:
|
What HTTP server is being used? I have the same problem, but with "Expect" header on LiteSpeed and PHP 7.4 (LSAPI). Here is request made by Guzzle:
and
"Expect" header is being zeroed with spaces instead of being removed. Switching to PHP 8.0 seems to fix the problem, but PHP 8.0 is not using "Expect" header. Currently it can be worked around with:
I suspect it might be related to LiteSpeed or LSAPI. |
Very interesting! The Expect header looks like a more likely cause than Accept, and there could also be legitimate reasons for it being removed from the headers at some point in the chain. I suppose it’s not being added due to the uploaded file specifically being an animated gif, but because it’s over some size threshold. A quick search doesn’t show any reports of similar bugs due to the header being changed to spaces, so it’s tricky to find exactly where it’s happening. At least it doesn’t look like a Guzzle bug, and we have a few workarounds now — thanks @Zerg2000! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you for your contributions. |
Guzzle version(s) affected: 7.3, dev-master
PHP version: 7.4.19
cURL version: 7.77.0
Description
When used to make a multipart POST request containing an animated GIF, the guzzle client adds an HTTP header consisting only of whitespace (6 spaces in the name, 12 in the value). This invalid header causes server errors when using strict HTTP message implementations such as nyholm/psr7.
How to reproduce
results in apache_request_headers() looking like this:
…and $_SERVER containing this key/value:
For the moment, I’ll leave my test page https://micropub.taprootproject.com/upload.php as it is, a no-op which prints the results of
apache_request_headers()
.Additional context
This seems to occur only when uploading animated gifs. I tried two different animated gifs and one static gif. Both animated gifs caused the empty header, the static one did not.
Making the same request via command line curl 7.64.1 doesn’t include the mysterious header: shell commands and output
When using nyholm/psr7-server, a request containing invalid headers such as this one results in the following stack trace:
The text was updated successfully, but these errors were encountered: