MCPcopy Create free account
hub / github.com/3rdparty/libprocess / send

Method send

src/http.cpp:1135–1185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1133 close(false) {}
1134
1135 Future<Response> send(const Request& request, bool streamedResponse)
1136 {
1137 if (!disconnection.future().isPending()) {
1138 return Failure("Disconnected");
1139 }
1140
1141 if (close) {
1142 return Failure("Cannot pipeline after 'Connection: close'");
1143 }
1144
1145 if (request.type == Request::PIPE) {
1146 if (request.reader.isNone()) {
1147 return Failure("Request reader must be set for PIPE request");
1148 }
1149
1150 if (!request.body.empty()) {
1151 return Failure("Request body must be empty for PIPE request");
1152 }
1153
1154 Option<string> contentLength = request.headers.get("Content-Length");
1155 if (request.headers.contains("Content-Length")) {
1156 return Failure("'Content-Length' cannot be set for PIPE request");
1157 }
1158 }
1159
1160 if (!request.keepAlive) {
1161 close = true;
1162 }
1163
1164 // We must chain the calls to Socket::send as it
1165 // otherwise interleaves data across calls.
1166 network::Socket socket_ = socket;
1167
1168 sendChain = sendChain
1169 .then([socket_, request]() {
1170 return _send(socket_, encode(request));
1171 });
1172
1173 // If we can't write to the socket, disconnect.
1174 sendChain
1175 .onFailed(defer(self(), [this](const string& failure) {
1176 disconnect(failure);
1177 }));
1178
1179 Promise<Response> promise;
1180 Future<Response> response = promise.future();
1181
1182 pipeline.push(std::make_tuple(streamedResponse, std::move(promise)));
1183
1184 return response;
1185 }
1186
1187 Future<Nothing> disconnect(const Option<string>& message = None())
1188 {

Callers

nothing calls this directly

Calls 10

FailureClass · 0.85
_sendFunction · 0.85
deferFunction · 0.85
isPendingMethod · 0.80
futureMethod · 0.80
pushMethod · 0.80
encodeFunction · 0.70
emptyMethod · 0.45
getMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected