From 62219add6906cafdaf020f74b1385798df1837c5 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 20 Jun 2016 09:40:35 -0400 Subject: [PATCH] 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. --- include/beast/http/impl/message_v1.ipp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/beast/http/impl/message_v1.ipp b/include/beast/http/impl/message_v1.ipp index d0b69e4e..e2a2568d 100644 --- a/include/beast/http/impl/message_v1.ipp +++ b/include/beast/http/impl/message_v1.ipp @@ -8,6 +8,7 @@ #ifndef BEAST_HTTP_IMPL_MESSAGE_V1_IPP #define BEAST_HTTP_IMPL_MESSAGE_V1_IPP +#include #include #include #include @@ -87,7 +88,11 @@ prepare_content_length(prepare_info& pi, std::true_type) { 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(); }