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

Method handle_res_hdr

lib_acl_cpp/src/http/http_aclient.cpp:609–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609bool http_aclient::handle_res_hdr(int status)
610{
611 if (status != HTTP_CHAT_OK) {
612 logger_error("http response head error, status=%d", status);
613 return false;
614 }
615
616 // ���� HTTP ��Ӧͷ
617 http_hdr_res_parse(hdr_res_);
618
619 // �� C HTTP ��Ӧͷת���� C++ HTTP ��Ӧͷ�����ص����෽��
620 http_header header(*hdr_res_);
621 if (!this->on_http_res_hdr(header)) {
622 return false;
623 }
624
625 keep_alive_ = header.get_keep_alive();
626
627 // ����� websocket ͨ�ŷ�ʽ����ת�� websocket ��������
628 if (status_ == HTTP_ACLIENT_STATUS_WS_HANDSHAKE) {
629 acl_assert(ws_in_ && ws_out_);
630
631 // HTTP ��Ӧ״̬������ 101��������� websocket ����ʧ��
632 if (hdr_res_->reply_status != 101) {
633 logger_error("invalid status=%d for websocket",
634 hdr_res_->reply_status);
635 this->on_ws_handshake_failed(hdr_res_->reply_status);
636 return false;
637 }
638
639 // �ص����෽����֪ͨ WS �������
640 if (!this->on_ws_handshake()) {
641 return false;
642 }
643 return true;
644 }
645
646 // ������������ HTTP ��������
647
648 if (http_res_) {
649 http_res_free(http_res_);
650 }
651 http_res_ = http_res_new(hdr_res_);
652
653 // �����Ӧ����Ϊ GZIP ѹ�����ݣ����û��������Զ���ѹ���ܣ�����Ҫ����
654 // ��ѹ�����������Ӧ���ݽ��н�ѹ
655 if (unzip_ && header.is_transfer_gzip() && zlib_stream::zlib_load_once()) {
656 zstream_ = NEW zlib_stream();
657 if (!zstream_->unzip_begin(false)) {
658 logger_error("unzip_begin error");
659 delete zstream_;
660 zstream_ = NULL;
661 } else {
662 // gzip ��Ӧ������ǰ���� 10 �ֽڵ�ͷ���ֶ�
663 gzip_header_left_ = 10;
664 }
665 }
666

Callers 1

http_res_hdr_cllbackMethod · 0.80

Calls 11

http_hdr_res_parseFunction · 0.85
http_res_freeFunction · 0.85
http_res_newFunction · 0.85
http_res_body_get_asyncFunction · 0.85
unzip_beginMethod · 0.80
get_astreamMethod · 0.80
zlib_streamClass · 0.50
on_http_res_hdrMethod · 0.45
on_ws_handshakeMethod · 0.45
on_http_res_finishMethod · 0.45

Tested by

no test coverage detected