MCPcopy Create free account
hub / github.com/apache/trafficserver / string502

Function string502

plugins/slice/response.cc:51–87  ·  view source on GitHub ↗

Form a 502 response, preliminary

Source from the content-addressed store, hash-verified

49
50// Form a 502 response, preliminary
51std::string
52string502(int const httpver)
53{
54 static std::string msg;
55 static std::mutex mutex;
56 std::lock_guard<std::mutex> const guard(mutex);
57
58 if (msg.empty()) {
59 std::string bodystr;
60 bodystr.append("<html>\n");
61 bodystr.append("<head><title>502 Bad Gateway</title></head>\n");
62 bodystr.append("<body bgcolor=\"white\">\n");
63 bodystr.append("<center><h1>502 Bad Gateway: Missing/Malformed "
64 "Content-Range</h1></center>");
65 bodystr.append("<hr><center>ATS/");
66 bodystr.append(TS_VERSION_STRING);
67 bodystr.append("</center>\n");
68 bodystr.append("</body>\n");
69 bodystr.append("</html>\n");
70
71 char hverstr[64];
72 int const hlen =
73 snprintf(hverstr, sizeof(hverstr), "HTTP/%d.%d 502 Bad Gateway\r\n", TS_HTTP_MAJOR(httpver), TS_HTTP_MINOR(httpver));
74 msg.append(hverstr, hlen);
75
76 char clenstr[1024];
77 int const clen = snprintf(clenstr, sizeof(clenstr), "%lu", bodystr.size());
78 msg.append("Content-Length: ");
79 msg.append(clenstr, clen);
80 msg.append("\r\n");
81
82 msg.append("\r\n");
83 msg.append(bodystr);
84 }
85
86 return msg;
87}
88
89void
90form416HeaderAndBody(HttpHeader &header, int64_t const contentlen, std::string const &bodystr)

Callers 1

handleFirstServerHeaderFunction · 0.85

Calls 3

emptyMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected