ponylang / http_server

Pony library for building HTTP server applications.
https://ponylang.github.io/http_server/
BSD 2-Clause "Simplified" License
30 stars 8 forks source link

Always set content-length #71

Closed SeanTAllen closed 9 months ago

SeanTAllen commented 10 months ago

Not setting it makes some clients unhappy.

mfelsche commented 10 months ago

I do understand the reason to come up with this fix, but I would suggest another way to fix it. Either we remove the None part from the function argument, or we add a check in both the .bytes() and .array() method, that adds a content-length of 0 if it is not yet set and if no Transfer-Encoding: chunked header is set. In this case the Content-Length header must be omitted.

SeanTAllen commented 10 months ago

@mfelsche i think that the "send no body" helper methods that work with content length of None (or would work with such a change) are a big boon. For something like a one shot redirect, one shouldn't have to supply bytes. I'm not sure what the best way to accomplish is while playing nice with chunked content. This seems relatively small, do you have time to take over?

mfelsche commented 10 months ago

I can take this over and try to ensure that all responses created have a content-length header, unless they are chunked.

SeanTAllen commented 10 months ago

awesome. thanks @mfelsche. i am sure you will do a better job than i would.