Boost logo

Boost :

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

In this code, extracted from one of the examples in the documentation,

    // Set up the response, starting with the common fields
    response<string_body> res;
    res.version = 11;
    res.set(field::server, "test");


    // We return responses indicating an error if
    // we do not recognize the request method.
    res.set(field::content_type, "text/plain");
    res.body = "Invalid request-method '" + req.method_string().to_string()
+ "'";

    // Send the response
    write(stream, res, ec);

field::content_length isn't set. Will Beast insert Content-Length based on
the body size, or will it send the response with the field missing?

The reason I ask is that I foresee forgetting the content_length to be a
common mistake, and an asymptomatic one.

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