官术网_书友最值得收藏!

The request object

HTTP request and response messages are similar, consisting of the following:

  • A status line, which for a request would resemble GET/index.html HTTP/1.1, and for a response would resemble HTTP/1.1 200 OK
  • Zero or more headers, which in a request might include Accept-Charset: UTF-8 or From: user@server.com, and in responses might resemble Content-Type: text/html and Content-Length: 1024
  • A message body, which for a response might be an HTML page, and for a POST request might be some form data

We've seen how HTTP server interfaces in Node are expected to expose a request handler, and how this handler will be passed some form of a request and response object, each of which implement a readable or writable stream.

We will cover the handling of POST data and Header data in more depth later in this chapter. Before we do, let's go over how to parse out some of the more straightforward information contained in a request.

主站蜘蛛池模板: 泰来县| 同德县| 谷城县| 彭山县| 息烽县| 凤凰县| 依安县| 裕民县| 新田县| 肃北| 沅江市| 长春市| 拉萨市| 武汉市| 奎屯市| 全椒县| 阿克| 上饶市| 山东省| 马尔康县| 康保县| 建始县| 乐亭县| 平潭县| 茶陵县| 益阳市| 洱源县| 和田市| 阿鲁科尔沁旗| 手游| 金湖县| 泰兴市| 余江县| 长子县| 格尔木市| 涿州市| 承德市| 大宁县| 晋城| 临潭县| 神木县|