原文在這 http://www.chmod777self.com/2013/08/sigh.html 不解釋 自己看 求performance也不是這樣搞的
parser->method = (enum http_method) 0; parser->index = 1; switch (ch) { case ‘C’: parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT / break; case ‘D’: parser->method = HTTP_DELETE; break; case ‘G’: parser->method = HTTP_GET; break; case ‘H’: parser->method = HTTP_HEAD; break; case ‘L’: parser->method = HTTP_LOCK; break; case ‘M’: parser->method = HTTP_MKCOL; / or MOVE, MKACTIVITY, MERGE, M-SEARCH / break; case ‘N’: parser->method = HTTP_NOTIFY; break; case ‘O’: parser->method = HTTP_OPTIONS; break; case ‘P’: parser->method = HTTP_POST; / or PROPFIND|PROPPATCH|PUT|PATCH|PURGE / break; case ‘R’: parser->method = HTTP_REPORT; break; case ‘S’: parser->method = HTTP_SUBSCRIBE; / or SEARCH / break; case ‘T’: parser->method = HTTP_TRACE; break; case ‘U’: parser->method = HTTP_UNLOCK; / or UNSUBSCRIBE */ break; default: SET_ERRNO(HPE_INVALID_METHOD); goto error; } parser->state = s_req_method; …