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

Method addField

Libraries/Http/HttpConnection.cpp:204–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202 if (boundaryValue.isEmpty())
203 return Result::Error(HttpResultCategory, HttpError::MultipartWriterBoundaryEmpty);
204 if (boundaryValue.sizeInBytes() >= sizeof(boundaryStorage))
205 return Result::Error(HttpResultCategory, HttpError::MultipartBoundaryTooLong);
206 if (not scHttpMultipartBoundaryIsSafe(boundaryValue))
207 return Result::Error(HttpResultCategory, HttpError::MultipartWriterBoundaryUnsafe);
208 ::memcpy(boundaryStorage, boundaryValue.bytesWithoutTerminator(), boundaryValue.sizeInBytes());
209 boundary = StringSpan::fromNullTerminated(boundaryStorage, StringEncoding::Ascii);
210 return Result(true);
211}
212
213Result HttpMultipartWriter::addField(StringSpan fieldName, StringSpan value)
214{
215 if (boundary.isEmpty())
216 return Result::Error(HttpResultCategory, HttpError::MultipartWriterBoundaryMissing);
217 if (fieldName.isEmpty())
218 return Result::Error(HttpResultCategory, HttpError::MultipartWriterFieldNameEmpty);
219 if (not scHttpMultipartQuotedParameterIsSafe(fieldName))

Callers 1

Calls 4

ResultClass · 0.50
sizeInBytesMethod · 0.45
isEmptyMethod · 0.45

Tested by 1