Skip to content
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

how to handle C-L for unknown methods #1095

Open
reschke opened this issue Sep 15, 2022 · 3 comments
Open

how to handle C-L for unknown methods #1095

reschke opened this issue Sep 15, 2022 · 3 comments
Labels

Comments

@reschke
Copy link
Contributor

reschke commented Sep 15, 2022

https://httpwg.org/specs/rfc9110.html#field.content-length has:

A user agent SHOULD send Content-Length in a request when the method defines a meaning for enclosed content and it is not sending Transfer-Encoding. For example, a user agent normally sends Content-Length in a POST request even when the value is 0 (indicating empty content). A user agent SHOULD NOT send a Content-Length header field when the request message does not contain content and the method semantics do not anticipate such data.

I don't see how a sender can implement the "SHOULD NOT" correctly unless it happens to know the semantics of the method (which may not be the case for newly introduced methods).

@royfielding
Copy link
Member

A user agent is expected to understand the semantics of any method it chooses to use, even if it is acting on downloaded instructions (e.g., javascript).

@reschke
Copy link
Contributor Author

reschke commented Sep 16, 2022

But what does this mean, for instance, for an HTTP client library? How is it supposed to know? Are you saying that the program that uses the library needs to tell the library?

See openjdk/jdk#8017 and apache/httpcomponents-core#360.

@royfielding
Copy link
Member

The person programming the library has to know and incorporate that into the code or calling parameters that implement a request and process the response. IOW, they deliberately choose to send content (or not) and the client has to send the correct header fields for that choice. The UA is the code calling the HTTP client library. A client library that allows arbitrary method construction just needs to know the difference (provide an API that distinguishes) between "no content" and "content of length 0". E.g., null versus empty string.

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

No branches or pull requests

2 participants