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

Method run

lib_fiber/samples-c++/https_client/https_request.cpp:16–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16void* 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
63bool https_request::do_plain(acl::http_request& req)
64{

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