Boost logo

Boost :

Subject: Re: [boost] [beast] Automatic content-length?
From: Peter Dimov (lists_at_[hidden])
Date: 2017-07-02 13:40:44

Vinnie Falco wrote:
> > The reason I ask is that I foresee forgetting the content_length to be a
> > common mistake, and an asymptomatic one.
> Well it wouldn't be asymptomatic in a real server since the other end
> would hang, waiting for the "end of stream" to denote the end of the HTTP
> message.

A real server would use persistent connections, but there any many unreal
ones that just close the connection at the end of the response.

> Beast will only set the content length if you ask it to, by calling
> message::prepare_payload. The library does not perform any validation on
> caller-provided HTTP inputs.

This is completely sound from a theoretical design perspective, but
forgetting to call prepare_payload will still be very common.

Are there legitimate use cases in which one would send a response lacking
Content-Length, with a body that has a known size?

Boost list run by bdawes at, gregod at, cpdaniel at, john at