diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-18 22:17:49 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-27 17:28:44 +0300 |
commit | 35359f038f571dc46de3d14af72a2bc911fb0a24 (patch) | |
tree | de3e89d678e78b9efc4d395274fd7ccc68f4a213 /web/server/apache/request.ixx | |
parent | 8ad672cc7211952716ffe1fbf76c179b4f1149e3 (diff) |
Implement brep-monitor
Diffstat (limited to 'web/server/apache/request.ixx')
-rw-r--r-- | web/server/apache/request.ixx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/web/server/apache/request.ixx b/web/server/apache/request.ixx new file mode 100644 index 0000000..119fd2e --- /dev/null +++ b/web/server/apache/request.ixx @@ -0,0 +1,45 @@ +// file : web/server/apache/request.ixx -*- C++ -*- +// 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; + } + } +} |