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

Method write_gzip

lib_acl_cpp/src/http/http_client.cpp:209–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209bool http_client::write_gzip(ostream& out, const void* data, size_t len)
210{
211 acl_assert(zstream_);
212
213 if (buf_ == NULL) {
214 buf_ = NEW string(4096);
215 } else {
216 buf_->clear();
217 }
218
219 // ��ѹ�����������
220 if (data && len > 0) {
221 // ���ӷ�ѹ�������ܳ���
222 gzip_total_in_ += (unsigned int) len;
223
224 // ���� crc32 �������
225 gzip_crc32_ = zstream_->crc32_update(gzip_crc32_, data, len);
226
227 // �Ըö����ݽ���ѹ������
228 if (!zstream_->zip_update((const char*) data, (int) len, buf_)) {
229 logger_error("zip_update error!");
230 return false;
231 }
232
233 // ���Ϊ�գ���ֱ�ӷ��أ��ȴ��´ε�д����
234 if (buf_->empty()) {
235 return true;
236 }
237
238 data = buf_->c_str();
239 len = buf_->size();
240 }
241
242 // д�� zstream �������������ܻ�������ݣ�ͬʱ����ѹ������
243 else {
244 // ������ݳ�����Ч
245 unsigned total_in = (unsigned) zstream_->get_zstream()->total_in;
246 if (total_in != gzip_total_in_) {
247 logger_warn("total_in: %d != gzip_total_in_: %d",
248 total_in, gzip_total_in_);
249 }
250
251 if (!zstream_->zip_finish(buf_)) {
252 logger_error("zip_finish error!");
253 return false;
254 }
255
256 if (buf_->empty()) {
257 return true;
258 }
259
260 data = buf_->c_str();
261 len = buf_->size();
262 }
263
264 // �鴫�䷽ʽ���ѹ������
265 if (chunked_transfer_) {
266 if (write_chunk(out, data, len)) {

Callers

nothing calls this directly

Calls 10

crc32_updateMethod · 0.80
zip_updateMethod · 0.80
zip_finishMethod · 0.80
fflushMethod · 0.80
stringClass · 0.50
clearMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected