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

Method run

lib_acl_cpp/samples/ssl/https_request/https_request.cpp:27–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27void* 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
79bool https_request::do_plain(acl::http_request& req)
80{

Callers

nothing calls this directly

Calls 10

request_headerMethod · 0.80
set_keep_aliveMethod · 0.80
set_content_typeMethod · 0.80
print_headerMethod · 0.80
http_statusMethod · 0.80
requestMethod · 0.45
get_clientMethod · 0.45
header_valueMethod · 0.45
parseMethod · 0.45
get_stypeMethod · 0.45

Tested by

no test coverage detected