This is the problem that I have encountered when I write a simple application with Express+ajax+swig. The HTTP module is still not understood.
Later on the internet to see a cloud habitat community, "node. js HTTP request and Response", here to do a simple summary.
The client sends a request to the server to respond
This process can be abstracted into a and b two locations between the communication, and then the person is abstracted into a request body or response body, what the person carries is called the request body encapsulated data.
The more official saying:
1. A client-initiated request to the server is equivalent to writing a stream to the server
2. Server-side Read client stream
3. The response of the server to the client is equivalent to writing a stream to the client
4. The client reads the response from the service side.
The client side can use Http.get (). Http.request (), which is the client, which is involved in the client request and the client when the server-side response data arrives, respectively, corresponding to the Req and res in the Http.get and Http.request methods.
The server is primarily Http.createserver (function (req,res) {}), and the Req and res in the server correspond to two processes on the service side when the client request body data arrives and the server responds.
When you understand these methods of the HTTP module, you should look at either the client or the server. The Req and RES objects involved in such a method are better understood.
HTTP Module Understanding (ii)