| 25 | } |
| 26 | |
| 27 | void* https_request::run(void) |
| 28 | { |
| 29 | acl::http_header& hdr = request_.request_header(); |
| 30 | hdr.set_url(url_) |
| 31 | .set_host(host_) |
| 32 | .set_content_type("text/plain") |
| 33 | .set_keep_alive(true); |
| 34 | |
| 35 | if (!request_.request(NULL, 0)) { |
| 36 | printf("send request error\r\n"); |
| 37 | return NULL; |
| 38 | } |
| 39 | |
| 40 | acl::http_client* conn = request_.get_client(); |
| 41 | conn->print_header("http response header"); |
| 42 | |
| 43 | int http_status = request_.http_status(); |
| 44 | printf(">>>http status=%d\r\n", http_status); |
| 45 | |
| 46 | const char* ptr = request_.header_value("Content-Type"); |
| 47 | if (ptr == NULL || *ptr == 0) { |
| 48 | printf("Content-Type empty!\r\n"); |
| 49 | return NULL; |
| 50 | } |
| 51 | |
| 52 | acl::http_ctype ctype; |
| 53 | ctype.parse(ptr); |
| 54 | |
| 55 | // ��Ӧͷ�������͵������� |
| 56 | const char* stype = ctype.get_stype(); |
| 57 | |
| 58 | bool ret; |
| 59 | |
| 60 | if (stype == NULL) { |
| 61 | ret = do_plain(request_); |
| 62 | } else if (strcasecmp(stype, "xml") == 0) { |
| 63 | ret = do_xml(request_); |
| 64 | } else if (strcasecmp(stype, "json") == 0) { |
| 65 | ret = do_json(request_); |
| 66 | } else { |
| 67 | ret = do_plain(request_); |
| 68 | } |
| 69 | |
| 70 | if (ret) { |
| 71 | printf("%s(%d): read ok!\r\n", __FILE__, __LINE__); |
| 72 | } else { |
| 73 | printf("read error\r\n"); |
| 74 | } |
| 75 | |
| 76 | return NULL; |
| 77 | } |
| 78 | |
| 79 | bool https_request::do_plain(acl::http_request& req) |
| 80 | { |
nothing calls this directly
no test coverage detected