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