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

Function test1

lib_acl_cpp/samples/ssl/ssl_client/ssl_client.cpp:57–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57static void test1(const char* domain, int port, bool use_gzip, bool use_ssl)
58{
59 // ���� WEB ����������
60
61 acl::string addr;
62 addr << domain << ':' << port;
63
64 acl::socket_stream client;
65 if (!client.open(addr.c_str(), 60, 60)) {
66 std::cout << "connect " << addr.c_str()
67 << " error!" << std::endl;
68 return;
69 }
70
71 // ���ʹ�� SSL ��ʽ������� SSL ���ֹ���
72 if (use_ssl) {
73 acl::polarssl_io* ssl = new acl::polarssl_io(*__ssl_conf, false);
74 if (client.setup_hook(ssl) == ssl) {
75 std::cout << "open ssl client " << addr.c_str()
76 << " error!" << std::endl;
77 ssl->destroy();
78 return;
79 }
80 }
81
82 // ���� HTTP ����ͷ
83 acl::http_header header;
84 header.set_url("/")
85 .set_host(domain)
86 .accept_gzip(use_gzip)
87 .set_keep_alive(false);
88 // mail.126.com �Ƚ������ʱ�ͻ���Ҫ���ѹ��������Ҳ�᷵��ѹ�����ݣ����Դ˴�
89 // ǿ��Ҫ���ѹ������
90 if (!use_gzip) {
91 header.add_entry("Accept-Encoding", "text/plain");
92 }
93
94 acl::string request;
95 header.build_request(request);
96
97 std::cout << "request(len: " << request.length() << "):" << std::endl;
98 std::cout << "----------------------------------------" << std::endl;
99 std::cout << request.c_str();
100 std::cout << "----------------------------------------" << std::endl;
101
102 // ���� HTTP GET ����ͷ
103 if (!client.write(request)) {
104 std::cout << "write to " << addr.c_str() <<
105 " error!" << std::endl;
106 return;
107 }
108
109 // ��ȡ HTTP ���������
110
111 char buf[8192];
112 size_t size;
113 int ret;
114

Callers 1

mainFunction · 0.70

Calls 10

set_keep_aliveMethod · 0.80
accept_gzipMethod · 0.80
openMethod · 0.45
c_strMethod · 0.45
setup_hookMethod · 0.45
destroyMethod · 0.45
build_requestMethod · 0.45
lengthMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…