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

Method run

lib_acl_cpp/samples/http_request2/main.cpp:27–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 ~http_request_test() {}
26
27 bool run(void)
28 {
29 http_request req(server_addr_);
30
31 // ���� HTTP ����ͷ�ֶ�
32
33 string ctype("text/");
34 ctype << stype_ << "; charset=" << charset_;
35
36 http_header& hdr = req.request_header(); // ����ͷ���������
37 hdr.set_url(url_);
38 hdr.set_content_type(ctype);
39 hdr.set_host(domain_);
40
41 // ���� HTTP ��������
42 if (req.request(NULL, 0) == false)
43 {
44 logger_error("send http request to %s error",
45 server_addr_.c_str());
46 return false;
47 }
48
49 acl::string line;
50
51 while (true)
52 {
53 if (req.body_gets(line) == false)
54 break;
55 printf(">>>[%s], len: %d\r\n", line.c_str(),
56 (int) line.size());
57 line.clear();
58 }
59
60 if (req.body_gets(line))
61 printf(">>last data: %s\r\n", line.c_str());
62
63 return true;
64 }
65
66private:
67 string server_addr_; // web ��������ַ

Callers 1

mainFunction · 0.45

Calls 7

request_headerMethod · 0.80
set_content_typeMethod · 0.80
requestMethod · 0.45
c_strMethod · 0.45
body_getsMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected