blob: 3bd843db106b304a0be0a7d5562c5972283a8515 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// file : web/apache/request.ixx -*- C++ -*-
// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#include <http_protocol.h> // ap_*()
#include <sstream> // stringbuf
namespace web
{
namespace apache
{
inline int request::
flush ()
{
if (std::stringbuf* b = dynamic_cast<std::stringbuf*> (out_buf_.get ()))
{
// Response content is buffered.
//
std::string s (b->str ());
if (!s.empty ())
{
try
{
state (request_state::writing);
if (ap_rwrite (s.c_str (), s.length (), rec_) < 0)
rec_->status = HTTP_REQUEST_TIME_OUT;
}
catch (const invalid_request& e)
{
rec_->status = e.status;
}
}
out_.reset ();
out_buf_.reset ();
}
return rec_->status == HTTP_OK || state_ >= request_state::writing
? OK
: rec_->status;
}
}
}
|