| 141 | } |
| 142 | |
| 143 | int 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 | |
| 164 | TEST(http_client, post) { |
| 165 | system("mkdir -p /tmp/ease_ut/http_test/"); |
nothing calls this directly
no test coverage detected