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

Function form416HeaderAndBody

plugins/slice/response.cc:89–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void
90form416HeaderAndBody(HttpHeader &header, int64_t const contentlen, std::string const &bodystr)
91{
92 header.removeKey(TS_MIME_FIELD_LAST_MODIFIED, TS_MIME_LEN_LAST_MODIFIED);
93 header.removeKey(TS_MIME_FIELD_EXPIRES, TS_MIME_LEN_EXPIRES);
94 header.removeKey(TS_MIME_FIELD_ETAG, TS_MIME_LEN_ETAG);
95 header.removeKey(TS_MIME_FIELD_ACCEPT_RANGES, TS_MIME_LEN_ACCEPT_RANGES);
96
97 header.setStatus(TS_HTTP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE);
98 char const *const reason = TSHttpHdrReasonLookup(TS_HTTP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE);
99 header.setReason(reason, strlen(reason));
100
101 char bufstr[256];
102 int buflen = snprintf(bufstr, sizeof(bufstr), "%lu", bodystr.size());
103 header.setKeyVal(TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH, bufstr, buflen);
104
105 static char const *const ctypestr = "text/html";
106 static int const ctypelen = strlen(ctypestr);
107 header.setKeyVal(TS_MIME_FIELD_CONTENT_TYPE, TS_MIME_LEN_CONTENT_TYPE, ctypestr, ctypelen);
108
109 buflen = snprintf(bufstr, 255, "*/%" PRId64, contentlen);
110 header.setKeyVal(TS_MIME_FIELD_CONTENT_RANGE, TS_MIME_LEN_CONTENT_RANGE, bufstr, buflen);
111}

Callers 1

handleFirstServerHeaderFunction · 0.85

Calls 6

TSHttpHdrReasonLookupFunction · 0.85
removeKeyMethod · 0.80
setReasonMethod · 0.80
setKeyValMethod · 0.80
setStatusMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected