mirror of
https://github.com/boostorg/beast.git
synced 2025-08-01 22:04:34 +02:00
Initialize Writer in prepare:
Writer requires a call to Writer::init to call content_length. This changes prepare to correctly call init. A consequences is that prepare can now throw unexpectedly for user-defined writers that can fail their initialization.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#ifndef BEAST_HTTP_IMPL_MESSAGE_V1_IPP
|
#ifndef BEAST_HTTP_IMPL_MESSAGE_V1_IPP
|
||||||
#define BEAST_HTTP_IMPL_MESSAGE_V1_IPP
|
#define BEAST_HTTP_IMPL_MESSAGE_V1_IPP
|
||||||
|
|
||||||
|
#include <beast/core/error.hpp>
|
||||||
#include <beast/http/rfc7230.hpp>
|
#include <beast/http/rfc7230.hpp>
|
||||||
#include <beast/http/detail/has_content_length.hpp>
|
#include <beast/http/detail/has_content_length.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
@@ -87,7 +88,11 @@ prepare_content_length(prepare_info& pi,
|
|||||||
std::true_type)
|
std::true_type)
|
||||||
{
|
{
|
||||||
typename Body::writer w(msg);
|
typename Body::writer w(msg);
|
||||||
//w.init(ec); // VFALCO This is a design problem!
|
// VFALCO This is a design problem!
|
||||||
|
error_code ec;
|
||||||
|
w.init(ec);
|
||||||
|
if(ec)
|
||||||
|
throw system_error{ec};
|
||||||
pi.content_length = w.content_length();
|
pi.content_length = w.content_length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user