原来node的http parser是这样坑爹的
发布于 7 年前 作者 asoedarren 9127 次浏览 最后一次编辑是 4 年前

原文在這 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; …

5 回复

没重复,这样不可以么

好像判断是有问题,仅对首字母进行判断~

从这个issue上看,是因为node没做自定义HTTP方法的支持。

目前还是这么判断的

回到顶部