aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-build-log.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-20 19:11:42 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-20 19:11:42 +0300
commit8c0326c9433d47dfbeab8d1514512de1160d5792 (patch)
tree8cb394dc35ddaaadf2c53f86c821f287fc22f5a3 /mod/mod-build-log.cxx
parent4b5c7b13f0ebd44c05b50ef8c3e56b0d02bfc4fe (diff)
Fix messed up build_log handler response
Diffstat (limited to 'mod/mod-build-log.cxx')
-rw-r--r--mod/mod-build-log.cxx39
1 files changed, 27 insertions, 12 deletions
diff --git a/mod/mod-build-log.cxx b/mod/mod-build-log.cxx
index ab9ab12..57135b6 100644
--- a/mod/mod-build-log.cxx
+++ b/mod/mod-build-log.cxx
@@ -197,23 +197,36 @@ handle (request& rq, response& rs)
// We have all the data so don't buffer the response content.
//
+ // Note that after we started to write the response content we need to be
+ // accurate not throwing any exceptions, that would mess up the response.
+ //
ostream& os (rs.content (200, "text/plain;charset=utf-8", false));
- os << "package: " << b->package_name << endl
- << "version: " << b->package_version << endl
- << "toolchain: " << b->toolchain_name << '-' << b->toolchain_version
- << endl
- << "config: " << b->configuration << endl
- << "machine: " << b->machine << " (" << b->machine_summary << ")"
- << endl
- << "target: " << b->target.string () << endl
- << "timestamp: ";
-
- butl::to_stream (os, b->timestamp, "%Y-%m-%d %H:%M:%S%[.N] %Z", true, true);
- os << endl << endl;
+ auto print_header = [&os, &b] ()
+ {
+ os << "package: " << b->package_name << endl
+ << "version: " << b->package_version << endl
+ << "toolchain: " << b->toolchain_name << '-' << b->toolchain_version
+ << endl
+ << "config: " << b->configuration << endl
+ << "machine: " << b->machine << " (" << b->machine_summary << ")"
+ << endl
+ << "target: " << b->target.string () << endl
+ << "timestamp: ";
+
+ butl::to_stream (os,
+ b->timestamp,
+ "%Y-%m-%d %H:%M:%S%[.N] %Z",
+ true /* special */,
+ true /* local */);
+
+ os << endl << endl;
+ };
if (op.empty ())
{
+ print_header ();
+
for (const auto& r: b->results)
os << r.operation << ": " << r.status << endl;
@@ -233,6 +246,8 @@ handle (request& rq, response& rs)
if (i == r.end ())
config_expired ("no operation");
+ print_header ();
+
os << op << ": " << i->status << endl << endl
<< i->log;
}