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

Method zeroLengthResponse

Tests/Libraries/Http/HttpAsyncClientTest.cpp:1640–1691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1638 }});
1639 client.setTransportSetup({[&setupCalled](HttpAsyncClientTransportSetup&) -> Result
1640 {
1641 setupCalled = true;
1642 return fixtureError(HttpAsyncClientFixtureError::UnexpectedTransportSetup);
1643 }});
1644
1645 const Result result = client.get(loop, "https://not-resolvable.invalid/");
1646 SC_TEST_EXPECT(result.isError(HttpAsyncClientFixtureCategory, HttpAsyncClientFixtureError::PreflightRejected));
1647 SC_TEST_EXPECT(preflightCalled);
1648 SC_TEST_EXPECT(not setupCalled);
1649 SC_TEST_EXPECT(client.close());
1650 SC_TEST_EXPECT(loop.close());
1651}
1652
1653void SC::HttpAsyncClientTest::externalConnectorOwnsConnectionEstablishment()
1654{
1655 AsyncEventLoop loop;
1656 SC_TEST_EXPECT(loop.create());
1657
1658 ServerConnection connections[1];
1659 HttpAsyncServer httpServer;
1660 const uint16_t port = report.mapPort(26130);
1661 SC_TEST_EXPECT(httpServer.init(Span<ServerConnection>(connections)));
1662 SC_TEST_EXPECT(httpServer.start(loop, "127.0.0.1", port));
1663
1664 ClientConnection clientStorage;
1665 HttpAsyncClient client;
1666 ResponseCollector collector;
1667 TimeoutGuard timeout;
1668
1669 struct Context
1670 {
1671 HttpAsyncClientTest* test = nullptr;
1672 ResponseCollector* collector = nullptr;
1673 HttpAsyncServer* server = nullptr;
1674
1675 HttpConnectionBase* connection = nullptr;
1676 AsyncEventLoop* loop = nullptr;
1677 AsyncSocketConnect connect;
1678
1679 Function<void(Result)> complete;
1680 Function<void(Result)> fail;
1681
1682 bool connectorCalled = false;
1683 bool connected = false;
1684 bool setupCalled = false;
1685
1686 Result onConnect(HttpAsyncClientExternalConnection& request)
1687 {
1688 test->recordExpectation("external connector connection", request.connection != nullptr);
1689 test->recordExpectation("external connector loop", request.eventLoop != nullptr);
1690 test->recordExpectation("external connector URL",
1691 request.url != nullptr and request.url->hostname == "not-resolvable.invalid");
1692 test->recordExpectation("external connector complete", request.complete.isValid());
1693 test->recordExpectation("external connector fail", request.fail.isValid());
1694

Callers

nothing calls this directly

Calls 15

mapPortMethod · 0.80
startResponseMethod · 0.80
sendHeadersMethod · 0.80
formatFunction · 0.50
createMethod · 0.45
initMethod · 0.45
startMethod · 0.45
addHeaderMethod · 0.45
endMethod · 0.45
attachMethod · 0.45
detachMethod · 0.45
sizeInBytesMethod · 0.45

Tested by

no test coverage detected