暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

一个http请求的旅程

手机用户7421 2025-06-04
60

#发起一个http请求。
$ curl -o /dev/null -v http://example.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Host example.com:80 was resolved.
* IPv6: 2606:2800:21f:cb07:6820:80da:af6b:8b2c
* IPv4: 93.184.215.14
* Trying 93.184.215.14:80...
* Trying [2606:2800:21f:cb07:6820:80da:af6b:8b2c]:80...
* Immediate connect fail for 2606:2800:21f:cb07:6820:80da:af6b:8b2c: Network is unreachable
* Connected to example.com (93.184.215.14) port 80
> GET / HTTP/1.1
> Host: example.com
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Age: 422312
< Cache-Control: max-age=604800
< Content-Type: text/html; charset=UTF-8
< Date: Tue, 19 Nov 2024 16:01:26 GMT
< Etag: "3147526947"
< Expires: Tue, 26 Nov 2024 16:01:26 GMT
< Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
< Server: ECAcc (sed/58C9)
< Vary: Accept-Encoding
< X-Cache: HIT
< Content-Length: 1256
<
{ [1256 bytes data]
100 1256 100 1256 0 0 2600 0 --:--:-- --:--:-- --:--:-- 2600
* Connection #0 to host example.com left intact

1、首先是域名解析:

* Host example.com:80 was resolved.
* IPv6: 2606:2800:21f:cb07:6820:80da:af6b:8b2c
* IPv4: 93.184.215.14

2、建立TCP链接

* Trying 93.184.215.14:80...
* Trying [2606:2800:21f:cb07:6820:80da:af6b:8b2c]:80...
* Immediate connect fail for 2606:2800:21f:cb07:6820:80da:af6b:8b2c: Network is unreachable
* Connected to example.com (93.184.215.14) port 80

其中IPV6不可达 ,IPV4 正常

3、开始发送http请求

> GET / HTTP/1.1
> Host: example.com
> User-Agent: curl/8.5.0
> Accept: */*

4、服务器响应

< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Age: 422312
< Cache-Control: max-age=604800
< Content-Type: text/html; charset=UTF-8
< Date: Tue, 19 Nov 2024 16:01:26 GMT
< Etag: "3147526947"
< Expires: Tue, 26 Nov 2024 16:01:26 GMT
< Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
< Server: ECAcc (sed/58C9)
< Vary: Accept-Encoding
< X-Cache: HIT
< Content-Length: 1256
<
{ [1256 bytes data]
100 1256 100 1256 0 0 2600 0 --:--:-- --:--:-- --:--:-- 2600
* Connection #0 to host example.com left intact



「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论