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

Method save_total

lib_acl_cpp/src/http/http_download.cpp:119–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool http_download::save_total(const char* body, size_t len)
120{
121 // ���Ͳ��� range �ֶε���������
122
123 http_method_t method = body && len > 0
124 ? HTTP_METHOD_POST : HTTP_METHOD_GET;
125
126 // ���� HTTP ����ͷ��Ϣ
127 req_->request_header().set_method(method);
128
129 // ���� HTTP ��������
130 if (!req_->request(body, len)) {
131 logger_error("send request error, url: %s", url_);
132 return false;
133 }
134
135 http_client* conn = req_->get_client();
136 if (conn == NULL) {
137 logger_fatal("no connect to server");
138 }
139
140 // �ص�������ӿ�ʵ��
141 if (!on_response(conn)) {
142 logger_error("deny url(%s)'s download", url_);
143 return false;
144 }
145
146 // ��������
147 acl_int64 length = conn->body_length();
148
149 // �ص�������ӿ�ʵ��
150 if (!on_length(length)) {
151 logger_error("deny url(%s)'s download", url_);
152 return false;
153 }
154
155 // ��ʼ�������������
156 return save(req_);
157}
158
159bool http_download::save_range(const char* body, size_t len,
160 acl_int64 range_from, acl_int64 range_to)

Callers

nothing calls this directly

Calls 4

request_headerMethod · 0.80
requestMethod · 0.45
get_clientMethod · 0.45
body_lengthMethod · 0.45

Tested by

no test coverage detected