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

Function parseContentLength

switch/source/server.cpp:166–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164 }
165
166 size_t parseContentLength(const std::string& headers)
167 {
168 size_t pos = headers.find("Content-Length:");
169 if (pos == std::string::npos) {
170 pos = headers.find("Content-length:");
171 }
172 if (pos == std::string::npos) {
173 return 0;
174 }
175 pos += strlen("Content-Length:");
176 while (pos < headers.size() && (headers[pos] == ' ' || headers[pos] == '\t')) {
177 pos++;
178 }
179 size_t end = headers.find("\r\n", pos);
180 if (end == std::string::npos) {
181 end = headers.size();
182 }
183 return (size_t)strtoul(headers.substr(pos, end - pos).c_str(), nullptr, 10);
184 }
185
186 // Streams the body of an upload request to `tmpPath`, tracking progress and
187 // honouring a receive cancel. `leftover` is the body bytes already read while

Callers 1

handleHttpRequestFunction · 0.70

Calls 2

findMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected