From 8c0326c9433d47dfbeab8d1514512de1160d5792 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 20 Jul 2018 19:11:42 +0300 Subject: Fix messed up build_log handler response --- mod/mod-build-log.cxx | 39 +++++++++++++++++++++++++++------------ 1 file 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; } -- cgit v1.1