| 153 | |
| 154 | template<bool isRequest, typename Body, typename StreamVariant> |
| 155 | void OutgoingHttpMessage<isRequest, Body, StreamVariant>::Flush(boost::asio::yield_context yc, bool finish) |
| 156 | { |
| 157 | m_CpuBoundWork.reset(); |
| 158 | |
| 159 | if (!Base::chunked() && !Base::has_content_length()) { |
| 160 | ASSERT(!m_SerializationStarted); |
| 161 | Base::prepare_payload(); |
| 162 | } |
| 163 | |
| 164 | std::visit( |
| 165 | [&](auto& stream) { |
| 166 | m_SerializationStarted = true; |
| 167 | |
| 168 | if (!m_Serializer.is_header_done()) { |
| 169 | boost::beast::http::write_header(*stream, m_Serializer); |
| 170 | } |
| 171 | |
| 172 | if (finish) { |
| 173 | Base::body().Finish(); |
| 174 | } |
| 175 | |
| 176 | boost::system::error_code ec; |
| 177 | boost::beast::http::async_write(*stream, m_Serializer, yc[ec]); |
| 178 | if (ec && ec != boost::beast::http::error::need_buffer) { |
| 179 | if (yc.ec_) { |
| 180 | *yc.ec_ = ec; |
| 181 | return; |
| 182 | } |
| 183 | BOOST_THROW_EXCEPTION(boost::system::system_error{ec}); |
| 184 | } |
| 185 | stream->async_flush(yc); |
| 186 | |
| 187 | ASSERT(m_Serializer.is_done() || !Base::body().Finished()); |
| 188 | }, |
| 189 | m_Stream |
| 190 | ); |
| 191 | } |
| 192 | |
| 193 | template<bool isRequest, typename Body, typename StreamVariant> |
| 194 | void OutgoingHttpMessage<isRequest, Body, StreamVariant>::StartStreaming() |
no test coverage detected