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

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.

主站蜘蛛池模板: 宜章县| 犍为县| 峨山| 望奎县| 全椒县| 弋阳县| 财经| 宝兴县| 台前县| 岑巩县| 永修县| 密山市| 湘阴县| 墨竹工卡县| 景德镇市| 乌鲁木齐县| 砚山县| 个旧市| 林周县| 措勤县| 瓮安县| 红河县| 宁陵县| 许昌市| 青阳县| 盘锦市| 天津市| 文水县| 扎赉特旗| 九寨沟县| 利津县| 唐海县| 鲁山县| 台东县| 五莲县| 仙桃市| 阿鲁科尔沁旗| 博兴县| 曲松县| 泌阳县| 佳木斯市|