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

Method sendHeaders

Libraries/Http/HttpConnection.cpp:1028–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026}
1027
1028Result HttpOutgoingMessage::sendHeaders(Function<void(AsyncBufferView::ID)> callback)
1029{
1030 SC_TRY_MSG(not headersSent, "Headers already sent");
1031 SC_TRY_MSG(responseHeaders.writtenBytes() != 0, "startResponse or startRequest must be the first call");
1032 SC_TRY_MSG(not(chunkedTransferEncodingEnabled and contentLengthAdded),
1033 "HttpOutgoingMessage does not support Content-Length with Transfer-Encoding");
1034
1035 if (chunkedTransferEncodingEnabled)
1036 {
1037 SC_TRY_MSG(destinationStream != nullptr, "HttpOutgoingMessage missing destination stream");
1038 SC_TRY(chunkedWritableStream.init(destinationStream->getBuffersPool(), *destinationStream));
1039 writableStream = &chunkedWritableStream;
1040 }
1041 else
1042 {
1043 writableStream = destinationStream;
1044 }
1045
1046 if (not connectionHeaderAdded)
1047 {
1048 if (forceDisableKeepAlive or not keepAlive)
1049 {
1050 SC_TRY(responseHeaders.appendLiteral("Connection: close\r\n",
1051 "HttpOutgoingMessage::appendAscii - header space is finished"));
1052 }
1053 else
1054 {
1055 SC_TRY(responseHeaders.appendLiteral("Connection: keep-alive\r\n",
1056 "HttpOutgoingMessage::appendAscii - header space is finished"));
1057 }
1058 }
1059 SC_TRY(responseHeaders.appendLiteral("\r\n", "HttpOutgoingMessage::appendAscii - header space is finished"));
1060 SC_TRY(destinationStream->write(responseHeaders.written(), move(callback)));
1061 headersSent = true;
1062 return Result(true);
1063}
1064
1065void HttpOutgoingMessage::reset()
1066{

Callers 15

blockingGetMethod · 0.80
blockingPostMethod · 0.80
blockingCustomHeadersMethod · 0.80
contentCodingPolicyMethod · 0.80
protocolPreferenceMethod · 0.80
proxyOptionsMethod · 0.80
methodCoverageMethod · 0.80
onEndMethod · 0.80
pollGetMethod · 0.80
pollConcurrentGetsMethod · 0.80

Calls 8

writtenMethod · 0.80
getBoundaryMethod · 0.80
ResultClass · 0.50
initMethod · 0.45
writeMethod · 0.45
sizeInBytesMethod · 0.45
appendMethod · 0.45
isValidMethod · 0.45

Tested by 15

blockingGetMethod · 0.64
blockingPostMethod · 0.64
blockingCustomHeadersMethod · 0.64
contentCodingPolicyMethod · 0.64
protocolPreferenceMethod · 0.64
proxyOptionsMethod · 0.64
methodCoverageMethod · 0.64
onEndMethod · 0.64
pollGetMethod · 0.64
pollConcurrentGetsMethod · 0.64