| 65 | } |
| 66 | |
| 67 | void CHttpDownload::on_body(const char* data, size_t dlen) |
| 68 | { |
| 69 | if (data == NULL && dlen == 0) |
| 70 | { |
| 71 | #ifdef WIN32 |
| 72 | printf("\n>> http reply body over, total: %I64d, %I64d\n", |
| 73 | content_length_, read_length_); |
| 74 | #else |
| 75 | printf("\n>> http reply body over, total: %lld, %lld\n", |
| 76 | content_length_, read_length_); |
| 77 | #endif |
| 78 | // ��������Ϊ��������Ƕ�̬����ģ�������Ҫ�ڴ˴��ͷ� |
| 79 | time_t end = time(NULL); |
| 80 | printf(">>spent %d seconds\n", (int)(end - begin_)); |
| 81 | return; |
| 82 | } |
| 83 | read_length_ += dlen; |
| 84 | http_off_t n = (read_length_ * 100) / content_length_; |
| 85 | #ifdef WIN32 |
| 86 | printf("%I64d%%\r", n); |
| 87 | #else |
| 88 | printf("%lld%%\r", n); |
| 89 | #endif |
| 90 | |
| 91 | if (out_.opened()) |
| 92 | out_.write(data, dlen); |
| 93 | } |
| 94 | |
| 95 | void CHttpDownload::on_error(acl::http_status_t errnum) |
| 96 | { |