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

proposal: Add new HttpEntity implementation for HTTP HEAD method #11937

Open
moznion opened this issue Aug 22, 2023 · 0 comments
Open

proposal: Add new HttpEntity implementation for HTTP HEAD method #11937

moznion opened this issue Aug 22, 2023 · 0 comments

Comments

@moznion
Copy link

moznion commented Aug 22, 2023

Currently, the Play framework has three implementations of HttpEntity: Strict, Streamed, and Chunked. These implementations assume the existence of a data body.

When a user of the framework wants to create a response for the HTTP HEAD method, the only option is to use the Streamed class with empty data (i.e., Source.empty()) because it needs to return the content-length header without a content body. However, the response to the HEAD method is not actually a streaming response, so using Streamed for this purpose feels a bit unconventional. Additionally, the Streamed#isKnownEmpty() method which comes from the parent class always returns false, but I believe it should return true for the HEAD response, as the body must always be empty.

Furthermore, the HEAD response requires the content-length header value. Therefore, it would be preferable to handle that as an actual numerical value in the code, rather than as an optional value. With this in mind, how about introducing a dedicated HttpEntity implementation for this purpose?

I have created a prototype for this: https://github.com/playframework/playframework/compare/main...moznion:playframework:http_head_entity?expand=1

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

No branches or pull requests

1 participant