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

Method handle_conn

lib_acl_cpp/samples/http_server/http_rpc.cpp:73–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void http_rpc::handle_conn(socket_stream* stream)
74{
75 // HTTP ��Ӧ������
76 http_response res(stream);
77 // ��Ӧ������Ϊ xml ��ʽ
78 res.response_header().set_content_type("text/html");
79
80 // �� HTTP ����ͷ
81 if (res.read_header() == false)
82 {
83 keep_alive_ = false;
84 return;
85 }
86
87 string buf;
88 // �� HTTP ����������
89 if (res.get_body(buf) == false)
90 {
91 keep_alive_ = false;
92 return;
93 }
94
95 http_client* client = res.get_client();
96
97 // �жϿͻ����Ƿ�ϣ�����ֳ�����
98 keep_alive_ = client->keep_alive();
99
100 // �������ݸ��ͻ���
101
102 res.response_header()
103 .set_status(200)
104 .set_keep_alive(keep_alive_)
105 .set_content_length(buf_size_);
106
107 res.response(res_buf_, buf_size_);
108
109 // ȡ�ÿͻ��˵�����
110 const char* action = client->request_param("action");
111 if (action && (strcasecmp(action, "stop") == 0
112 || strcasecmp(action, "quit") == 0))
113 {
114 proc_quit_ = true;
115 }
116}

Callers

nothing calls this directly

Calls 9

set_content_typeMethod · 0.80
set_keep_aliveMethod · 0.80
responseMethod · 0.80
request_paramMethod · 0.80
read_headerMethod · 0.45
get_bodyMethod · 0.45
get_clientMethod · 0.45
keep_aliveMethod · 0.45
set_statusMethod · 0.45

Tested by

no test coverage detected