这个HTTP的解析和我写串口通信的思想很像。就是对缓冲区出现的各种可能的情况都要分别做处理。
https://blog.csdn.net/huyanping/article/details/48162181
代码是在这里
https://github.com/huyanping/learning-http-protocol
。