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

Method on_body

lib_acl_cpp/samples/http_client/main.cpp:51–78  ·  view source on GitHub ↗

������ HTTP ��Ӧ��ʱ�Ļص�����

Source from the content-addressed store, hash-verified

49
50 // ������ HTTP ��Ӧ��ʱ�Ļص�����
51 virtual void on_body(const char* data, size_t dlen)
52 {
53 if (data == NULL && dlen == 0)
54 {
55#ifdef WIN32
56 printf("\n>> http reply body over, total: %I64d, %I64d\n",
57 content_length_, read_length_);
58#else
59 printf("\n>> http reply body over, total: %lld, %lld\n",
60 content_length_, read_length_);
61#endif
62 // ��������Ϊ��������Ƕ�̬����ģ�������Ҫ�ڴ˴��ͷ�
63 time_t end = time(NULL);
64 printf(">>spent %d seconds\n", (int)(end - begin_));
65
66 return;
67 }
68 read_length_ += dlen;
69 http_off_t n = (read_length_ * 100) / content_length_;
70#ifdef WIN32
71 printf("%s(%d): n=%I64d%%\r", __FUNCTION__, __LINE__, n);
72#else
73 printf("%s(%d): n=%lld%%\r", __FUNCTION__, __LINE__, n);
74#endif
75
76 if (out_.opened())
77 out_.write(data, dlen);
78 }
79
80 // ���������Ӧʧ��ʱ�Ļص�����
81 virtual void on_error(acl::http_status_t errnum)

Callers

nothing calls this directly

Calls 2

openedMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected