4. HTTp全解
protocol: 礼仪, 协议
4.1 Ip
IP(internet protocol): 定位, 封装.
IP(internet protocol)的两大作用
- 如何定位一台设备
- 如何封装数据报文
内网, 外网, 路由器 三者之间的关系
- 内网和外网沟通的唯一渠道就是路由器.
- 路由器会被分配一个外网IP, 不是固定的.内网中所有设备都是共享这个外网ip.
- 路由器会给内网中的设备分配一个内网IP, 例如: 192.168.1.3
几个特殊的内网ip
- 127.0.0.1: 表示自己
- 系统中hosts文件中定义了
127.0.0.1 localhost那么浏览器中写localhost,就会自动映射到127.0.0.1. 这个单词localhost, 我们也可以自己定义 - 0.0.0.0 不表示任何设备
4.2 端口
如同麦当劳的不同窗口, 提供不同服务. 这里==不同端口==,也提供不同的计算机服务.
常见的端口
- http: 80端口
- https: 443端口
- Ftp: 21端口
端口的规则
- 0到1023是系统端口, 不要用
- http-server的默认端口是8080
4.3 域名
域名和IP的对应关系是什么?
- 一个域名对应多个ip主机: 称之为负责均衡
- 多个域名对应一个ip主机, 称之为共享主机
DNS是什么?
==DNS域名服务器==: 根据域名查询ip.
www.xiedaimala.com 和 xiedaimala.com 的区别?
- xiedaimala.com 全部是:xiedaimala.com/
- 两者有同样的二级域名, 但是很有可能没有关系
- 例如: tzc.github.io和 ttt.github.io. 属于两个不同人的域名
4.4 URL
URL的组成?
URL需要注意的点?
- 路径没有必要有后缀.
- URL的全称是统一资源定位符
- 锚点不支持中文.==锚点不会传给服务器===. 无法在Network面板看到.
4.5 curl命令
galen@DESKTOP-VSIP5NV /d/soft/cmder
λ curl -v http://baidu.com
* Trying 39.156.69.79:80...
* Connected to baidu.com (39.156.69.79) port 80 (#0)
> GET / HTTP/1.1 //发送get请求, HTTP/1.1 的协议
> Host: baidu.com //我请求的域名是这个
> User-Agent: curl/7.71.1 //curl的版本协议是这个
> Accept: */* //我接受任何东西
>
* Mark bundle as not supporting multiuse //下面这一坨, 不需要了解什么意思.
< HTTP/1.1 200 OK
< Date: Mon, 21 Dec 2020 08:24:41 GMT
< Server: Apache
< Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
< ETag: "51-47cf7e6ee8400"
< Accept-Ranges: bytes
< Content-Length: 81
< Cache-Control: max-age=86400
< Expires: Tue, 22 Dec 2020 08:24:41 GMT
< Connection: Keep-Alive
< Content-Type: text/html
<
<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/"> //你需要重新访问这个url
</html>
* Connection #0 to host baidu.com left intact