| 21 | static acl::string __host; |
| 22 | |
| 23 | static void http_client(ACL_FIBER *fiber, const char* addr) |
| 24 | { |
| 25 | acl::string body; |
| 26 | acl::http_request req(addr, __conn_timeout, __rw_timeout); |
| 27 | acl::http_header& hdr = req.request_header(); |
| 28 | |
| 29 | acl::istream::set_rbuf_size(20480); |
| 30 | |
| 31 | req.set_ssl(__ssl_conf); |
| 32 | |
| 33 | for (int i = 0; i < __max_loop; i++) { |
| 34 | hdr.set_url("/") |
| 35 | .set_content_type("text/plain") |
| 36 | .set_keep_alive(true); |
| 37 | if (!__host.empty()) { |
| 38 | hdr.set_host(__host); |
| 39 | } |
| 40 | |
| 41 | if (i == 0) { |
| 42 | acl::string hdrbuf; |
| 43 | hdr.build_request(hdrbuf); |
| 44 | printf("request header:\r\n%s\r\n", hdrbuf.c_str()); |
| 45 | } |
| 46 | if (!req.request(NULL, 0)) { |
| 47 | printf("send request error\r\n"); |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | if (!req.get_body(body)) { |
| 52 | printf("get_body error\r\n"); |
| 53 | break; |
| 54 | } |
| 55 | |
| 56 | if (i < 1) { |
| 57 | if (body.size() < 1000) { |
| 58 | printf(">>>fiber-%d: body: %s\r\n", |
| 59 | acl_fiber_id(fiber), body.c_str()); |
| 60 | } else { |
| 61 | printf(">>>fiber-%d: body len: %zd\r\n", |
| 62 | acl_fiber_id(fiber), body.size()); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | __total_count++; |
| 67 | body.clear(); |
| 68 | req.reset(); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | static void fiber_client(ACL_FIBER *fiber, void *ctx) |
| 73 | { |
no test coverage detected
searching dependent graphs…