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