| 25 | ~http_request_test() {} |
| 26 | |
| 27 | bool run(void) |
| 28 | { |
| 29 | http_request req(server_addr_); |
| 30 | |
| 31 | // ���� HTTP ����ͷ�ֶ� |
| 32 | |
| 33 | string ctype("text/"); |
| 34 | ctype << stype_ << "; charset=" << charset_; |
| 35 | |
| 36 | http_header& hdr = req.request_header(); // ����ͷ��������� |
| 37 | hdr.set_url(url_); |
| 38 | hdr.set_content_type(ctype); |
| 39 | hdr.set_host(domain_); |
| 40 | |
| 41 | // ���� HTTP �������� |
| 42 | if (req.request(NULL, 0) == false) |
| 43 | { |
| 44 | logger_error("send http request to %s error", |
| 45 | server_addr_.c_str()); |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | acl::string line; |
| 50 | |
| 51 | while (true) |
| 52 | { |
| 53 | if (req.body_gets(line) == false) |
| 54 | break; |
| 55 | printf(">>>[%s], len: %d\r\n", line.c_str(), |
| 56 | (int) line.size()); |
| 57 | line.clear(); |
| 58 | } |
| 59 | |
| 60 | if (req.body_gets(line)) |
| 61 | printf(">>last data: %s\r\n", line.c_str()); |
| 62 | |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | private: |
| 67 | string server_addr_; // web ��������ַ |
no test coverage detected