HTTP Module Understanding (ii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.