且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解析HTTP标头的子集以标识主机Web地址

更新时间:2022-04-05 06:22:08

我认为HTTP标头没有按位分段。在HTTP中,每个标题都以\\\\ n结尾。所以,你只需要寻找下一个\\\\ n然后选择它。

I think there is no bitwise segmentation of HTTP header. in the HTTP, each header ends with "\r\n". so, all you need is to look for the next "\r\n" and pick it out.

类似的东西:

char httpRe[] ="GET / HTTP/1.1\r\nHost: http://***.com/\r\nReferer: https://www.google.com/\r\n\r\n";
char * parser = strtok (httpRe,"\r\n");
while (parser != NULL){
   printf ("%s\n",parser);
   parser = strtok (NULL, "\r\n");
}

这是您要找的?