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

Method emptyResponseHelper

Tests/Libraries/Http/HttpAsyncServerTest.cpp:511–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509 SC_TEST_EXPECT(eventLoop.create());
510
511 using HttpConnectionType = HttpAsyncConnection<2, 2, 8 * 1024, 8 * 1024>;
512
513 HttpConnectionType connections[1];
514 HttpAsyncServer httpServer;
515 const uint16_t serverPort = report.mapPort(6157);
516 SC_TEST_EXPECT(httpServer.init(Span<HttpConnectionType>(connections)));
517 SC_TEST_EXPECT(httpServer.start(eventLoop, "127.0.0.1", serverPort));
518
519 httpServer.onRequest = [this](HttpConnection& connection) { SC_TEST_EXPECT(connection.response.sendEmpty(204)); };
520
521 HttpTestClient client;
522 client.callback = [this, &httpServer](HttpTestClient& result)
523 {
524 StringView response(result.getResponse());
525 SC_TEST_EXPECT(response.containsString("204 No Content"));
526 SC_TEST_EXPECT(response.containsString("Content-Length: 0"));
527 SC_TEST_EXPECT(httpServer.stop());
528 };
529
530 String endpoint = StringEncoding::Ascii;
531 SC_TEST_EXPECT(StringBuilder::format(endpoint, "http://127.0.0.1:{}/empty", serverPort));
532 SC_TEST_EXPECT(client.get(eventLoop, endpoint.view()));
533
534 AsyncLoopTimeout timeout;
535 timeout.callback = [this](AsyncLoopTimeout::Result&)
536 { SC_TEST_EXPECT("Test never finished. Event Loop is stuck. Timeout expired." && false); };
537 SC_TEST_EXPECT(timeout.start(eventLoop, TimeMs{2000}));
538 eventLoop.excludeFromActiveCount(timeout);
539
540 SC_TEST_EXPECT(eventLoop.run());
541 SC_TEST_EXPECT(httpServer.close());
542 SC_TEST_EXPECT(eventLoop.close());
543}
544
545void SC::HttpAsyncServerTest::chunkedRequestDecoding()
546{
547 AsyncEventLoop eventLoop;
548 SC_TEST_EXPECT(eventLoop.create());
549
550 using HttpConnectionType = HttpAsyncConnection<2, 2, 8 * 1024, 8 * 1024>;
551

Callers

nothing calls this directly

Calls 13

mapPortMethod · 0.80
sendEmptyMethod · 0.80
getResponseMethod · 0.80
formatFunction · 0.50
createMethod · 0.45
initMethod · 0.45
startMethod · 0.45
stopMethod · 0.45
getMethod · 0.45
viewMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected