| 28 | } |
| 29 | |
| 30 | void* http_thread::run() |
| 31 | { |
| 32 | char domain[256]; |
| 33 | unsigned short port; |
| 34 | |
| 35 | if (acl::http_utils::get_addr(url_.c_str(), domain, |
| 36 | sizeof(domain), &port) == false) |
| 37 | { |
| 38 | logger_error("invalid url: %s", url_.c_str()); |
| 39 | return NULL; |
| 40 | } |
| 41 | |
| 42 | char host[256], *phost; |
| 43 | if (port == 80) |
| 44 | phost = domain; |
| 45 | else |
| 46 | { |
| 47 | snprintf(host, sizeof(host), "%s:%d", domain, port); |
| 48 | phost = host; |
| 49 | } |
| 50 | |
| 51 | struct timeval begin0; |
| 52 | gettimeofday(&begin0, NULL); |
| 53 | |
| 54 | struct timeval begin, end; |
| 55 | |
| 56 | // ���� HTTP �������������ʱ |
| 57 | gettimeofday(&begin, NULL); |
| 58 | acl::socket_stream* conn = connect_server(); |
| 59 | gettimeofday(&end, NULL); |
| 60 | spent_connect_ = util::stamp_sub(&end, &begin); |
| 61 | |
| 62 | if (conn == NULL) |
| 63 | return NULL; |
| 64 | |
| 65 | gettimeofday(&begin, NULL); |
| 66 | if (http_request(conn, phost) == false) |
| 67 | logger_error("http request failed!"); |
| 68 | gettimeofday(&end, NULL); |
| 69 | |
| 70 | struct timeval finish; |
| 71 | gettimeofday(&finish, NULL); |
| 72 | |
| 73 | spent_http_ = util::stamp_sub(&end, &begin); |
| 74 | |
| 75 | spent_total_ = spent_dns_ + util::stamp_sub(&finish, &begin0); |
| 76 | |
| 77 | delete conn; |
| 78 | return NULL; |
| 79 | } |
| 80 | |
| 81 | acl::socket_stream* http_thread::connect_server() |
| 82 | { |
nothing calls this directly
no test coverage detected