8-3httpparser.cpp
shell1
./8-3httpparser 127.0.0.1 8888
shell2
curl 127.0.0.1:8888/index.html
shell1
The request method is GET
The request URL is: /index.html
the request host is: 127.0.0.1:8888
I can not handle this header
I can not handle this header
shell2
I get a correct result
curl 是常用的命令行工具,用来请求 Web 服务器。
状态机主要是简化了程序的分支,降低了复杂度,每个状态对应的一个处理的case。http解析的过程可能有各种返回值,如果用if else写程序逻辑挺麻烦的