You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
Currently, the Play framework has three implementations of HttpEntity:
Strict
,Streamed
, andChunked
. 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 thecontent-length
header without a content body. However, the response to the HEAD method is not actually a streaming response, so usingStreamed
for this purpose feels a bit unconventional. Additionally, theStreamed#isKnownEmpty()
method which comes from the parent class always returnsfalse
, but I believe it should returntrue
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
The text was updated successfully, but these errors were encountered: