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

Method onRequestBodyData

Libraries/Http/HttpAsyncServer.cpp:326–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324 // Register before starting the body stream, which can synchronously emit buffered body data.
325 struct AfterWrite
326 {
327 HttpAsyncServer& pself;
328 HttpConnection& client;
329
330 void operator()()
331 {
332 SC_HTTP_ASSERT_RELEASE(client.response.getWritableStream().eventFinish.removeListener(*this));
333
334 // Determine if we should keep the connection alive
335 const bool underMaxRequests =
336 (pself.maxRequestsPerConnection == 0) or (client.requestCount + 1 < pself.maxRequestsPerConnection);
337 const bool shouldKeepAlive = client.response.getKeepAlive() and underMaxRequests and
338 not client.getReadableTransportStream().isEnded();
339
340 if (shouldKeepAlive and pself.state == State::Started) // We may get some after-writes after server stop
341 {
342 SC_HTTP_ASSERT_RELEASE(client.socket.isValid());
343 // Increment request count
344 client.requestCount++;
345
346 // Reset request and response for next request
347 client.request.setHeaderMemory(client.getHeaderMemory());
348 client.response.reset();
349
350 if (&client.getWritableTransportStream() == &client.writableSocketStream)
351 {
352 Result writableRes =
353 client.writableSocketStream.init(client.buffersPool, *pself.eventLoop, client.socket);
354 SC_HTTP_TRUST_RESULT(writableRes);
355 }
356
357 // Resume reading in any case to avoid deadlocking
358 client.getReadableTransportStream().resumeReading();
359
360 // Re-register for next request headers
361 EventDataListener dataListener{pself, client};

Callers 1

operator()Method · 0.80

Calls 5

onErrorFunction · 0.85
getReadableDataMethod · 0.80
processBodyDataMethod · 0.80
pauseMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected