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

Method addFile

Libraries/Http/HttpConnection.cpp:218–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218Result HttpMultipartWriter::addFile(StringSpan fieldName, StringSpan fileName, Span<const char> body,
219 StringSpan contentType)
220{
221 SC_TRY_MSG(boundary.sizeInBytes() > 0, "HttpMultipartWriter::addFile boundary not set");
222 SC_TRY_MSG(not fieldName.isEmpty(), "HttpMultipartWriter::addFile empty field name");
223 SC_TRY_MSG(scHttpMultipartQuotedParameterIsSafe(fieldName), "HttpMultipartWriter::addFile unsafe field name");
224 SC_TRY_MSG(fileName.isEmpty() or scHttpMultipartQuotedParameterIsSafe(fileName),
225 "HttpMultipartWriter::addFile unsafe file name");
226 SC_TRY_MSG(contentType.isEmpty() or scHttpHeaderValueIsSafe(contentType),
227 "HttpMultipartWriter::addFile unsafe content type");
228 SC_TRY_MSG(numParts < MaxParts, "HttpMultipartWriter::addFile too many parts");
229 Part& part = parts[numParts++];
230 part.partName = fieldName;
231 part.fileName = fileName;
232 part.contentType = contentType;
233 part.body = body;
234 return Result(true);
235}
236
237size_t HttpMultipartWriter::getContentLength() const
238{

Callers 7

configureSmallSCProgramFunction · 0.80
multipartUploadMethod · 0.80
configureZLibFilCFunction · 0.80
configureSingleFileLibsFunction · 0.80

Calls 5

scHttpHeaderValueIsSafeFunction · 0.85
ResultClass · 0.50
sizeInBytesMethod · 0.45
isEmptyMethod · 0.45

Tested by 3

configureSmallSCProgramFunction · 0.64
multipartUploadMethod · 0.64