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

Function contentLengthFrom

plugins/slice/server.cc:60–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60int64_t
61contentLengthFrom(HttpHeader const &header)
62{
63 int64_t bytes = 0;
64
65 char constr[1024];
66 int conlen = sizeof(constr);
67
68 // look for expected Content-Length field
69 bool const hasContentLength(header.valueForKey(TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH, constr, &conlen));
70
71 if (!hasContentLength) {
72 DEBUG_LOG("invalid response header, no Content-Length");
73 bytes = INT64_MAX;
74 } else {
75 // ensure null termination
76 constr[conlen] = '\0';
77 char *endptr = nullptr;
78 bytes = std::max(static_cast<int64_t>(0), static_cast<int64_t>(strtoll(constr, &endptr, 10)));
79 }
80
81 return bytes;
82}
83
84// Also reference server header
85enum HeaderState {

Callers 1

handleFirstServerHeaderFunction · 0.85

Calls 1

valueForKeyMethod · 0.80

Tested by

no test coverage detected