MCPcopy Create free account
hub / github.com/acl-dev/acl / run

Method run

lib_acl_cpp/samples/ssl/https_request_static/https_request.cpp:25–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void* 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
71bool https_request::do_plain(acl::http_request& req)
72{

Callers

nothing calls this directly

Calls 7

request_headerMethod · 0.80
set_keep_aliveMethod · 0.80
set_content_typeMethod · 0.80
requestMethod · 0.45
header_valueMethod · 0.45
parseMethod · 0.45
get_stypeMethod · 0.45

Tested by

no test coverage detected