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

Method get_body

lib_acl_cpp/src/http/http_response.cpp:107–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107bool http_response::get_body(xml& out, const char* to_charset /* = NULL */)
108{
109 if (!header_ok_) {
110 logger_error("header not read yet");
111 return false;
112 } else if (client_->body_length() == 0) {
113 return true;
114 } else if (client_->body_length() < 0) {
115 const char* method = client_->request_method();
116 if (method && (strcmp(method, "GET") == 0
117 || strcmp(method, "CONNECT") == 0)) {
118
119 return true;
120 }
121
122 logger_error("client request body length(%d) invalid",
123 (int) client_->body_length());
124 return false;
125 }
126
127 if (debug_) {
128 client_->print_header("----request---");
129 }
130
131 http_pipe* hp = get_pipe(to_charset);
132 if (hp) {
133 hp->append(&out);
134 }
135
136 string buf;
137 int ret;
138
139 while (true) {
140 // ѭ����ȡ�ͻ�������������
141 ret = client_->read_body(buf);
142 if (ret == 0) {
143 break;
144 }
145 if (ret < 0) {
146 logger_error("read client body error");
147 close();
148 return false;
149 }
150
151 // ��ʽ���� xml ��ʽ��������
152 if (hp) {
153 hp->update(buf.c_str(), ret);
154 } else {
155 out.update(buf.c_str());
156 }
157 if (debug_) {
158 printf("%s", buf.c_str());
159 }
160 }
161
162 if (hp) {
163 hp->update_end();
164 delete hp;

Callers

nothing calls this directly

Calls 9

request_methodMethod · 0.80
print_headerMethod · 0.80
closeFunction · 0.50
body_lengthMethod · 0.45
appendMethod · 0.45
read_bodyMethod · 0.45
updateMethod · 0.45
c_strMethod · 0.45
update_endMethod · 0.45

Tested by

no test coverage detected