| 300 | } |
| 301 | |
| 302 | http_status_t send_request(void) |
| 303 | { |
| 304 | string hdr_req; |
| 305 | if (!data_.callback->build_request(hdr_req)) { |
| 306 | return HTTP_ERR_REQ; |
| 307 | } |
| 308 | |
| 309 | // д HTTP ����ͷ |
| 310 | if (!client_.write(hdr_req.c_str(), hdr_req.length())) { |
| 311 | return HTTP_ERR_SEND; |
| 312 | } |
| 313 | |
| 314 | // ѭ������������л�����������ݣ���д HTTP ���������� |
| 315 | while (true) { |
| 316 | const string* data = data_.callback->get_body(); |
| 317 | if (data == NULL || data->empty()) { |
| 318 | break; |
| 319 | } |
| 320 | if (!client_.write(data->c_str(), data->length())) { |
| 321 | return HTTP_ERR_SEND; |
| 322 | } |
| 323 | } |
| 324 | return HTTP_OK; |
| 325 | } |
| 326 | |
| 327 | http_status_t read_respond_hdr(void) |
| 328 | { |