diff options
| author | Per Larsson <[email protected]> | 2021-11-01 14:36:28 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-11-01 14:36:28 +0100 |
| commit | 934881f5572778e17b973d29dfb0ad760f29025c (patch) | |
| tree | 28d9a952721f52e92e8ce55a3430620de91b607f /zenserver/diag/formatters.h | |
| parent | Added option --zen-upstream-dns that will be resolved to one or more endpoint. (diff) | |
| download | zen-934881f5572778e17b973d29dfb0ad760f29025c.tar.xz zen-934881f5572778e17b973d29dfb0ad760f29025c.zip | |
Upload cache record before blobs and call finalize when processing upstream to Jupiter.
Diffstat (limited to 'zenserver/diag/formatters.h')
| -rw-r--r-- | zenserver/diag/formatters.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/zenserver/diag/formatters.h b/zenserver/diag/formatters.h index 42f928efe..759df58d3 100644 --- a/zenserver/diag/formatters.h +++ b/zenserver/diag/formatters.h @@ -2,6 +2,11 @@ #pragma once +#include <zencore/compactbinary.h> +#include <zencore/compactbinaryvalidation.h> +#include <zencore/iobuffer.h> +#include <zencore/string.h> + ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> #include <fmt/format.h> @@ -17,7 +22,7 @@ struct fmt::formatter<cpr::Response> { using namespace std::literals; - if (Response.status_code == 200) + if (Response.status_code == 200 || Response.status_code == 201) { return fmt::format_to(Ctx.out(), "Url: {}, Status: {}, Bytes: {}/{} (Up/Down), Elapsed: {}s", @@ -32,18 +37,21 @@ struct fmt::formatter<cpr::Response> const auto It = Response.header.find("Content-Type"); const std::string_view ContentType = It != Response.header.end() ? It->second : "<None>"sv; - const bool IsBinary = ContentType == "application/x-ue-cb"sv || ContentType == "application/x-ue-comp"sv || - ContentType == "application/octet-stream"; - - if (IsBinary) + if (ContentType == "application/x-ue-cb"sv) { + zen::IoBuffer Body(zen::IoBuffer::Wrap, Response.text.data(), Response.text.size()); + zen::CbObjectView Obj(Body.Data()); + zen::ExtendableStringBuilder<256> Sb; + std::string_view Json = Obj.ToJson(Sb).ToView(); + return fmt::format_to(Ctx.out(), - "Url: {}, Status: {}, Bytes: {}/{} (Up/Down), Elapsed: {}s, Reason: '{}'", + "Url: {}, Status: {}, Bytes: {}/{} (Up/Down), Elapsed: {}s, Response: '{}', Reason: '{}'", Response.url.str(), Response.status_code, Response.uploaded_bytes, Response.downloaded_bytes, Response.elapsed, + Json, Response.reason); } else |