Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
52
第 6 章
request
和
response
对象
本章将学习
request
和
response
对象的重要内容。在
Express
应用中发生的一切,很大程度
上由它们开始,也由它们结束。如果使用
Express
构建一个
We
b
服务器,则大部分要做的
事情会始于一个
request
对象,而止于一个
response
对象。
这两个对象来自
Node
,
Express
则对它们做了扩展
。在深入探索这些对象能够带来什么之
前,先建立一点儿背景知识:客户端(通常指浏览器)是怎样向服务器请求一个页面,这
个页面又是怎样返回的。
6.1
 
URL
的各个组成部分
我们每天都会看见各种
URL
,但很少会去思考它们是怎么组成的。下面列举了一个
URL
的各个组成部分。
协议(protocol)
协议决定了请求将怎样传输。本书只会涉及
http
和
https
。其他常见协议包括
file
和
ftp
。
主机(host)
主机用来标识服务器。如果是在你的计算机(
localhost
)或本地网络上
,那么服务器可
以用一个名字或数字
IP
地址简单地标识
。在互联网中,主机会以顶级域名(
TLD
)结
尾,比如
.com
或
.net
。另外
,可能还会有
子域名
。子域名放在主机名的前面,怎么命
名都可以,比如
www
就是常见的子域名。子域名是可选添加的。
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099