Skip to content

Fix #79013: Content-Length missing when posting a curlFile with curl #5219

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

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Feb 28, 2020

Unfortunately, some Webservers (e.g. IIS) do not implement the (F)CGI
specifications correctly wrt. chunked uploads (i.e. Transfer-encoding:
chunked), but instead pass -1 as CONTENT_LENGTH to the CGI
application. However, our (F)CFI SAPIs (i.e. cgi and cgi-fcgi) do not
support this.

Therefore we do no longer do chunked uploads unless ext/curl has been
compiled with CURL_FILE_AS_STREAM for best interoperability. We only
make minimal modifications to the code for simplicity, and also because
we consider this commit a mere work-around for broken (F)CGI servers/
applications which have to deal with HTTP/1.1 requests (HTTP/2 and
later do no longer support Transfer-encoding: chunked, anyway).

Users who are sure that they upload CURLFiles to servers which support
chunked uploads are encouraged to build with CURL_FILE_AS_STREAM; we
introduce the PHP constant CURL_FILE_AS_STREAM to be able to retrieve
this information during run-time.

Unfortunately, some Webservers (e.g. IIS) do not implement the (F)CGI
specifications correctly wrt. chunked uploads (i.e. Transfer-encoding:
chunked), but instead pass `-1` as CONTENT_LENGTH to the CGI
application.  However, our (F)CFI SAPIs (i.e. cgi and cgi-fcgi) do not
support this.

Therefore we do no longer do chunked uploads unless ext/curl has been
compiled with `CURL_FILE_AS_STREAM` for best interoperability.  We only
make minimal modifications to the code for simplicity, and also because
we consider this commit a mere work-around for broken (F)CGI servers/
applications which have to deal with HTTP/1.1 requests (HTTP/2 and
later do no longer support Transfer-encoding: chunked, anyway).

Users who are sure that they upload CURLFiles to servers which support
chunked uploads are encouraged to build with `CURL_FILE_AS_STREAM`; we
introduce the PHP constant `CURL_FILE_AS_STREAM` to be able to retrieve
this information during run-time.
@cmb69
Copy link
Member Author

cmb69 commented Feb 28, 2020

I would like to get this into PHP 7.4.4, so the PR would have to be merged on Monday. Any objections?

Anyway, review would be appreciated!

@cmb69
Copy link
Member Author

cmb69 commented Mar 2, 2020

Closing in favor of PR #5228.

@cmb69 cmb69 closed this Mar 2, 2020
@cmb69 cmb69 deleted the cmb/79013 branch March 2, 2020 18:15
@pierrejoye
Copy link
Contributor

@cmb69 do you know a userland work around for this? It seems some distros does not have it (7.4.3 and 7.68.0 f.e.).

Facing this exact issue right now :)

@cmb69
Copy link
Member Author

cmb69 commented Aug 18, 2020

@pierrejoye sorry, I don't think there's a simple workaround; likely you'd have to construct the full payload manually. :(

@pierrejoye
Copy link
Contributor

pierrejoye commented Aug 19, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants