MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / parseContentLength

Function parseContentLength

3ds/source/server.cpp:90–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 }
89
90 static size_t parseContentLength(const std::string& headers)
91 {
92 size_t pos = headers.find("Content-Length:");
93 if (pos == std::string::npos) {
94 pos = headers.find("Content-length:");
95 }
96 if (pos == std::string::npos) {
97 return 0;
98 }
99 pos += strlen("Content-Length:");
100 while (pos < headers.size() && (headers[pos] == ' ' || headers[pos] == '\t')) {
101 pos++;
102 }
103 size_t end = headers.find("\r\n", pos);
104 if (end == std::string::npos) {
105 end = headers.size();
106 }
107 return (size_t)strtoul(headers.substr(pos, end - pos).c_str(), nullptr, 10);
108 }
109
110 // Per-recv idle timeout. The server is single-threaded, so without a bound a
111 // stalled (or malicious) client would hang the whole receiver indefinitely.

Callers 1

handleHttpRequestFunction · 0.70

Calls 2

findMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected