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

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.

主站蜘蛛池模板: 亚东县| 建平县| 九龙县| 家居| 淮南市| 青神县| 雷山县| 勐海县| 甘肃省| 安新县| 松原市| 广德县| 朝阳区| 沙田区| 宣化县| 崇左市| 金昌市| 松溪县| 江津市| 宁德市| 收藏| 广东省| 涡阳县| 宜兰县| 广昌县| 大同市| 长宁县| 宜兰市| 无极县| 滨海县| 新野县| 澎湖县| 乾安县| 南郑县| 武义县| 潮安县| 根河市| 贵定县| 汉中市| 神池县| 乾安县|