Skip to content

chunked POST forced, disable length check on read callback #13257

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 3 commits into from

Conversation

icing
Copy link
Contributor

@icing icing commented Apr 1, 2024

  • when an application forces HTTP/1.1 chunked transfer encoding by setting the corresponding header and instructs curl to use the CURLOPT_READFUNCTION, disregard any POST length information.
  • this establishes backward compatibility with previous curl versions

Applications are encouraged to not force "chunked", but rather set length information for a POST. By setting -1, curl will auto-select chunked on HTTP/1.1 and work properly on other HTTP versions.

refs #13229

- when an application forces HTTP/1.1 chunked transfer encoding
  by setting the corresponding header and instructs curl to use
  the CURLOPT_READFUNCTION, disregard any POST length information.
- this establishes backward compatibility with previous curl versions

Applications are encouraged to not force "chunked", but rather
set length information for a POST. By setting -1, curl will
auto-select chunked on HTTP/1.1 and work properly on other HTTP
versions.
lib/http.c Outdated
* is forced by the application, we disregard `postsize`. This is
* a backward compatibility decision to earlier versions where
* chunking disregarded this. See issue #13229. */
bool chunked = !!Curl_checkheaders(data, STRCONST("Transfer-Encoding"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should instead use data->req.upload_chunky ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that does not work. That flag is set after the installed reader is checked for known length.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! But then maybe the checks should at least be done the same way?

  bool chunked = FALSE;
  char *ptr = Curl_checkheaders(data, STRCONST("Transfer-Encoding"));
  if(ptr) {
    /* Some kind of TE is requested, check if 'chunked' is chosen */
    chunked =
      Curl_compareheader(ptr,
                         STRCONST("Transfer-Encoding:"), STRCONST("chunked"));
  }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It works for Git's case because we are setting chunked, but I guess some other caller setting Transfer-Encoding: gzip or something would confuse things. My understanding is that you can pass multiple items there (e.g, Transfer-Encoding: gzip, chunked), and I don't think that would match correctly here. But AFAICT none of that is new (and is certainly not something Git does).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added the check as suggested by @bagder.

We have a bit backward compatibility weirdness here. Ideally, we would either auto-reset post sizes between transfers OR require all applications to set it. But that would certainly also break some apps.

icing added 2 commits April 1, 2024 16:57
- ignore application desire to chunk on HTTP/2 and higher
- give information message that chunked encoding is suppressed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants