| 11 | } |
| 12 | |
| 13 | int main(int argc, char* argv[]) |
| 14 | { |
| 15 | int ch, max = 10; |
| 16 | bool accept_gzip = false, send_body = false; |
| 17 | acl::string addr("127.0.0.1:8194"); |
| 18 | |
| 19 | acl::acl_cpp_init(); |
| 20 | |
| 21 | while ((ch = getopt(argc, argv, "hs:n:zB")) > 0) |
| 22 | { |
| 23 | switch (ch) |
| 24 | { |
| 25 | case 'h': |
| 26 | usage(argv[0]); |
| 27 | return 0; |
| 28 | case 's': |
| 29 | addr = optarg; |
| 30 | break; |
| 31 | case 'n': |
| 32 | max = atoi(optarg); |
| 33 | break; |
| 34 | case 'z': |
| 35 | accept_gzip = true; |
| 36 | break; |
| 37 | case 'B': |
| 38 | send_body = true; |
| 39 | break; |
| 40 | default: |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | acl::log::stdout_open(true); |
| 46 | |
| 47 | acl::string buf(1024); |
| 48 | for (size_t i = 0; i < 1024; i++) |
| 49 | buf << 'X'; |
| 50 | |
| 51 | acl::http_request req(addr, 10, 10); |
| 52 | acl::string tmp(1024); |
| 53 | |
| 54 | for (int i = 0; i < max; i++) |
| 55 | { |
| 56 | acl::http_header& header = req.request_header(); |
| 57 | //header.set_method(acl::HTTP_METHOD_POST); |
| 58 | header.set_url("/"); |
| 59 | header.set_keep_alive(true); |
| 60 | header.accept_gzip(accept_gzip ? true : false); |
| 61 | //header.set_content_length(buf.length()); |
| 62 | |
| 63 | bool rc; |
| 64 | |
| 65 | if (send_body) |
| 66 | rc = req.request(buf.c_str(), buf.length()); |
| 67 | else |
| 68 | rc = req.request(NULL, 0); |
| 69 | |
| 70 | // 只所以将 build_request 放在 req.request 后面,是因为 |
nothing calls this directly
no test coverage detected
searching dependent graphs…