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

Method maxHeaderSizeError

Tests/Libraries/Http/HttpAsyncServerTest.cpp:743–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

741 SC_TEST_EXPECT(client.sendRaw(eventLoop, endpoint.view(), request));
742
743 AsyncLoopTimeout timeout;
744 timeout.callback = [this](AsyncLoopTimeout::Result&)
745 { SC_TEST_EXPECT("Test never finished. Event Loop is stuck. Timeout expired." && false); };
746 SC_TEST_EXPECT(timeout.start(eventLoop, TimeMs{2000}));
747 eventLoop.excludeFromActiveCount(timeout);
748
749 SC_TEST_EXPECT(eventLoop.run());
750 SC_TEST_EXPECT(not serverContext.sawRequest);
751 SC_TEST_EXPECT(serverContext.sawError);
752 SC_TEST_EXPECT(httpServer.close());
753 SC_TEST_EXPECT(eventLoop.close());
754}
755
756void SC::HttpAsyncServerTest::responseBodyHelpers()
757{
758 {
759 SC::AsyncBufferView buffers[4] = {};
760 SC::AsyncBuffersPool pool;
761 pool.setBuffers(buffers);
762
763 RecordedWritableStream writable;
764 SC_TEST_EXPECT(writable.init(pool));
765
766 ProbeHttpResponse response;
767 char headers[256] = {0};
768 response.setup(headers, writable);
769
770 SC_TEST_EXPECT(response.sendText(200, "hello"));
771 while (writable.flushOne()) {}
772
773 constexpr StringView expected = "HTTP/1.1 200 OK\r\n"
774 "Content-Type: text/plain; charset=utf-8\r\n"
775 "Content-Length: 5\r\n"
776 "Connection: keep-alive\r\n"
777 "\r\n"
778 "hello";
779 SC_TEST_EXPECT(StringSpan(writable.output.toSpanConst(), false, StringEncoding::Ascii) == expected);
780 }
781
782 {
783 SC::AsyncBufferView buffers[4] = {};
784 SC::AsyncBuffersPool pool;
785 pool.setBuffers(buffers);
786
787 RecordedWritableStream writable;
788 SC_TEST_EXPECT(writable.init(pool));
789
790 ProbeHttpResponse response;
791 char headers[256] = {0};
792 response.setup(headers, writable);
793
794 SC_TEST_EXPECT(response.sendRedirect(302, "/new-place"));
795 while (writable.flushOne()) {}
796

Callers

nothing calls this directly

Calls 12

mapPortMethod · 0.80
sendRawMethod · 0.80
resultMessageEqualsFunction · 0.70
formatFunction · 0.50
createMethod · 0.45
initMethod · 0.45
startMethod · 0.45
stopMethod · 0.45
viewMethod · 0.45
runMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected