HTTP简介
HTTP原理
- WebServer为Client提供网页浏览等服务,又称HTTPServer或WWWServer。
- HTTP采用B/S模型,Client和Server通过HTTP或HTTPS进行数据的传输。
- HTTP采用TCP链接,HTTP默认监听80端口,HTTPS默认监听443端口。
- HTTP的工作原理:
- 链接:Browser和WebServer建立链接,通过打开socket表明链接建立成功。
- 请求:Browser通过socket向WebServer提交请求,一般为HTTP的GET或POST。
- 应答:Server通过特定端口接收监听到的Web页面请求,若请求存在再通过HTTP发送Browser需要的信息;若请求不存在则返回错误提示。
- 关闭连接:每完成一次应答,就会断开一次链接。
查看访问网站的详细流程
curl -v
[root@front ~]
* Rebuilt URL to: www.baidu.com/
* Trying 153.3.238.110...
* TCP_NODELAY set
* Connected to www.baidu.com (153.3.238.110) port 80 (
> GET / HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: keep-alive
< Content-Length: 2381
< Content-Type: text/html
< Date: Sun, 02 Jun 2024 12:25:56 GMT
< Etag: "588604eb-94d"
< Last-Modified: Mon, 23 Jan 2017 13:28:11 GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
<
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=