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

Function body_check_handler

net/http/test/client_function_test.cpp:143–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143int body_check_handler(void*, Request &req, Response &resp, std::string_view) {
144 auto fs = photon::fs::new_localfs_adaptor("/tmp/ease_ut/http_test/");
145 DEFER(delete fs);
146
147 char buf[4096];
148 auto len_body = req.read(buf, 4096);
149 char buf_file[4096];
150 auto file = fs->open("ease-httpclient-posttestfile", O_RDONLY);
151 DEFER(delete file);
152 auto len_file = file->read(buf_file, 4096);
153 EXPECT_EQ(len_body, len_file);
154 EXPECT_EQ(0, strncmp(buf, buf_file, len_body));
155
156 resp.set_result(200);
157 std::string str = "success";
158 resp.headers.content_length(7);
159
160 resp.write((void*)str.data(), str.size());
161 return 0;
162}
163
164TEST(http_client, post) {
165 system("mkdir -p /tmp/ease_ut/http_test/");

Callers

nothing calls this directly

Calls 8

new_localfs_adaptorFunction · 0.85
set_resultMethod · 0.80
readMethod · 0.45
openMethod · 0.45
content_lengthMethod · 0.45
writeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected