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

Class AfterWrite

Libraries/Http/HttpAsyncServer.cpp:268–311  ·  view source on GitHub ↗

Register before starting the body stream, which can synchronously emit buffered body data.

Source from the content-addressed store, hash-verified

266 HttpAsyncServerTransportSetup setup;
267 setup.connection = &client;
268 setup.eventLoop = eventLoop;
269 setup.complete = {[this, &client](Result result) { onTransportSetupComplete(client, result); }};
270 setup.fail = {[this, &client](Result result)
271 {
272 if (onError.isValid())
273 {
274 onError(result);
275 }
276 closeAsync(client);
277 }};
278 return transportSetup(setup);
279}
280
281void HttpAsyncServer::onTransportSetupComplete(HttpConnection& client, Result result)
282{
283 if (not result)
284 {
285 if (onError.isValid())
286 {
287 onError(result);
288 }
289 closeAsync(client);
290 return;
291 }
292
293 Result setup = beginHttpConnection(client);
294 if (not setup)
295 {
296 if (onError.isValid())
297 {
298 onError(setup);
299 }
300 closeAsync(client);
301 }
302}
303
304void HttpAsyncServer::onStreamReceive(HttpConnection& client, AsyncBufferView::ID bufferID)
305{
306 Span<char> readData;
307 SC_HTTP_ASSERT_RELEASE(client.buffersPool.getWritableData(bufferID, readData));
308
309 Result headerWrite =
310 client.request.writeHeaders(maxHeaderSize, readData, client.getReadableTransportStream(), bufferID);
311 if (not headerWrite)
312 {
313 if (onError.isValid())
314 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected