| 777 | // Content-Type: application/octet-stream |
| 778 | |
| 779 | bool 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; |
no test coverage detected