Preliminary Research on http protocol
Recently, I have been using programs for downloading http web pages and files for many times. I was suddenly interested in the principle of the program and happened to see the socket-based http protocol, which made me very excited. After all, it took a long time to get in touch with the practical underlying protocol of socket and practice it in a small chat room. However, I don't know what specific examples in my life are completed by socket.
After reading various notes and documents, coupled with a code experiment, I finally got a preliminary idea of how to use this protocol.
The Protocol is divided into two parts: one is sent to the http server, calledRequest HeaderOne is received from there, and there will be a string before the official data, called the response header.
The two have their own formats. The specific parameter list and explanations are not written here. Here are some interesting things you may encounter.
1. Request Header "GET/\ r \ n"
In this way, the data body is directly obtained without feedback to the response header.
2. The request headers http1.0 and 1.1
In principle, 1.1 is better than 1.0 protocol, but in my actual use process, 1.0 gets feedback faster, and 1.1 takes several seconds to get feedback. Note: The test environment is the same.