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

Method readHeader

lib_acl_cpp/src/http/HttpServletRequest.cpp:779–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

777// Content-Type: application/octet-stream
778
779bool HttpServletRequest::readHeader(string* method_s)
780{
781 acl_assert(readHeaderCalled_ == false);
782 readHeaderCalled_ = true;
783
784 const char* method;
785
786 if (cgi_mode_) {
787 const char* ptr = acl_getenv("CONTENT_TYPE");
788 if (ptr && *ptr) {
789 content_type_.parse(ptr);
790 }
791
792 // �����Ǻ��� method����Ϊ acl_getenv �ڲ����ڴ����õ�
793 // ���ֲ߳̾����������ڴ�����ͬһ�߳��лᱻ�ظ�ʹ�ã�����
794 // ���� method ���Ա�֤ method ����������Ĺ���ȷ������
795 // �����󷽷�
796 method = acl_getenv("REQUEST_METHOD");
797 } else {
798 client_ = new (dbuf_->dbuf_alloc(sizeof(http_client)))
799 http_client(&stream_, false, true);
800 if (!client_->read_head()) {
801 req_error_ = HTTP_REQ_ERR_IO;
802 return false;
803 }
804
805 method = client_->request_method();
806 const char* ptr = client_->header_value("Content-Type");
807 if (ptr && *ptr) {
808 content_type_.parse(ptr);
809 }
810 }
811
812 if (method == NULL || *method == 0) {
813 req_error_ = HTTP_REQ_ERR_METHOD;
814 logger_error("method null");
815 return false;
816 }
817
818 // �����ַ������͵����󷽷�
819 method_s->copy(method);
820
821 if (strcasecmp(method, "GET") == 0) {
822 method_ = HTTP_METHOD_GET;
823 } else if (strcasecmp(method, "POST") == 0) {
824 method_ = HTTP_METHOD_POST;
825 } else if (strcasecmp(method, "PUT") == 0) {
826 method_ = HTTP_METHOD_PUT;
827 } else if (strcasecmp(method, "CONNECT") == 0) {
828 method_ = HTTP_METHOD_CONNECT;
829 } else if (strcasecmp(method, "PURGE") == 0) {
830 method_ = HTTP_METHOD_PURGE;
831 } else if (strcasecmp(method, "DELETE") == 0) {
832 method_ = HTTP_METHOD_DELETE;
833 } else if (strcasecmp(method, "HEAD") == 0) {
834 method_ = HTTP_METHOD_HEAD;
835 }else if (strcasecmp(method, "OPTIONS") == 0) {
836 method_ = HTTP_METHOD_OPTION;

Callers 1

getMethodMethod · 0.80

Calls 10

acl_getenvFunction · 0.85
dbuf_allocMethod · 0.80
read_headMethod · 0.80
request_methodMethod · 0.80
get_boundMethod · 0.80
getContentTypeFunction · 0.50
parseMethod · 0.45
header_valueMethod · 0.45
get_stypeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected