MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / getContentLength

Method getContentLength

Libraries/Http/HttpConnection.cpp:237–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237size_t HttpMultipartWriter::getContentLength() const
238{
239 size_t total = 0;
240 for (size_t idx = 0; idx < numParts; ++idx)
241 {
242 const Part& part = parts[idx];
243 total += 2 + boundary.sizeInBytes() + 2; // --boundary\r\n
244 total += sizeof("Content-Disposition: form-data; name=\"") - 1;
245 total += part.partName.sizeInBytes();
246 total += 1;
247 if (part.fileName.sizeInBytes() > 0)
248 {
249 total += sizeof("; filename=\"") - 1;
250 total += part.fileName.sizeInBytes();
251 total += 1;
252 }
253 total += 2;
254
255 if (part.contentType.sizeInBytes() > 0)
256 {
257 total += sizeof("Content-Type: ") - 1;
258 total += part.contentType.sizeInBytes();
259 total += 2;
260 }
261 total += 2;
262 total += part.body.sizeInBytes();
263 total += 2;
264 }
265 total += 2 + boundary.sizeInBytes() + 4; // --boundary--\r\n
266 return total;
267}
268//-------------------------------------------------------------------------------------------------------
269// HttpConnection
270//-------------------------------------------------------------------------------------------------------

Callers 2

responseHeaderHelpersMethod · 0.45
setMultipartMethod · 0.45

Calls 1

sizeInBytesMethod · 0.45

Tested by 1

responseHeaderHelpersMethod · 0.36