MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / TEST

Function TEST

net/http/test/server_function_test.cpp:52–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52TEST(http_server, headers) {
53 auto tcpserver = new_tcp_socket_server();
54 tcpserver->timeout(1000UL*1000);
55 tcpserver->bind_v4localhost();
56 tcpserver->listen();
57 DEFER(delete tcpserver);
58 auto server = new_http_server();
59 DEFER(delete server);
60 server->add_handler({nullptr, &idiot_handle});
61 tcpserver->set_handler(server->get_connection_handler());
62 tcpserver->start_loop();
63 auto client = new_http_client();
64 DEFER(delete client);
65 auto op = client->new_operation(Verb::GET, to_url(tcpserver, "/test"));
66 DEFER(client->destroy_operation(op));
67 auto exp_len = 20;
68 op->req.headers.range(0, exp_len - 1);
69 op->call();
70 EXPECT_EQ(200, op->resp.status_code());
71 char buf[4096];
72 auto ret = op->resp.read(buf, 4096);
73 EXPECT_EQ(exp_len, ret);
74 EXPECT_EQ(true, "test" == op->resp.headers["Test_Handle"]);
75}
76
77
78int body_check_handler(void*, Request &req, Response &resp, std::string_view) {

Callers

nothing calls this directly

Calls 15

new_tcp_socket_serverFunction · 0.85
new_http_serverFunction · 0.85
new_http_clientFunction · 0.85
to_urlFunction · 0.85
new_localfs_adaptorFunction · 0.85
new_fs_handlerFunction · 0.85
test_head_caseFunction · 0.85
new_proxy_handlerFunction · 0.85
add_handlerMethod · 0.80
test_caseFunction · 0.70
stringClass · 0.50
thread_sleepFunction · 0.50

Tested by

no test coverage detected