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

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.

主站蜘蛛池模板: 称多县| 内丘县| 乐至县| 鄂州市| 乡宁县| 郁南县| 昌图县| 舒兰市| 大田县| 西安市| 丰县| 晋宁县| 郁南县| 尤溪县| 通州市| 固阳县| 大竹县| 遂溪县| 宜春市| 高唐县| 满城县| 那坡县| 云梦县| 岢岚县| 荣成市| 罗城| 天祝| 洱源县| 宜州市| 滕州市| 高碑店市| 方山县| 治县。| 平阳县| 克拉玛依市| 鹤山市| 祥云县| 柏乡县| 抚松县| 建德市| 望奎县|