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

Method read_response_head

lib_acl_cpp/src/http/http_client.cpp:487–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487bool http_client::read_response_head(void)
488{
489 // �Է���һ����������ܵ��ϴ�����IJ������м����ݶ���
490 reset();
491
492 if (stream_ == NULL) {
493 logger_error("connect stream not open yet");
494 disconnected_ = true;
495 return false;
496 }
497 ACL_VSTREAM* vstream = stream_->get_vstream();
498 if (vstream == NULL) {
499 logger_error("connect stream null");
500 disconnected_ = true;
501 return false;
502 }
503
504 hdr_res_ = http_hdr_res_new();
505 int ret = http_hdr_res_get_sync(hdr_res_, vstream, vstream->rw_timeout);
506 if (ret == -1) {
507 http_hdr_res_free(hdr_res_);
508 hdr_res_ = NULL;
509 disconnected_ = true;
510 return false;
511 }
512
513 if (http_hdr_res_parse(hdr_res_) < 0) {
514 logger_error("parse response header error");
515 http_hdr_res_free(hdr_res_);
516 hdr_res_ = NULL;
517 disconnected_ = true;
518 return false;
519 }
520
521 // �鴫������ȼ����
522 if (!hdr_res_->hdr.chunked) {
523 // �����������Ӧʱ��ȷָ���˳���Ϊ 0 ���ʾ��û��������
524 if (hdr_res_->hdr.content_length == 0) {
525 body_finish_ = true;
526 return true;
527 }
528 }
529
530 if (!unzip_) {
531 return true;
532 }
533
534#define EQ(x, y) !strcasecmp((x), (y))
535
536 bool gzipped = false;
537 const char* ptr = http_hdr_entry_value(&hdr_res_->hdr, "Content-Encoding");
538 if (ptr) {
539 if (EQ(ptr, "gzip") || EQ(ptr, "x-gzip")) {
540 gzipped = true;
541 } else {
542 logger_warn("unknown compress format: %s", ptr);
543 }
544 }

Callers

nothing calls this directly

Calls 8

http_hdr_res_newFunction · 0.85
http_hdr_res_get_syncFunction · 0.85
http_hdr_res_freeFunction · 0.85
http_hdr_res_parseFunction · 0.85
http_hdr_entry_valueFunction · 0.85
unzip_beginMethod · 0.80
zlib_streamClass · 0.50
get_vstreamMethod · 0.45

Tested by

no test coverage detected