从tutorialspoint学习 HTTP
在 URI 部分(第三种方法),它说对 www.w3.org 的请求将打开到端口 80 的 TCP 连接并发送以下请求行:
GET /pub/WWW/TheProject.html HTTP/1.1
Host: www.w3.org
Run Code Online (Sandbox Code Playgroud)
在初始请求时,客户端设备如何知道要抓取的特定 .html 文件名?如果它是 index.html 或默认的其中之一,我会理解,但 TheProject.html 不是。
当您单击网页中的链接时,它具有要请求的文件名。将鼠标悬停在您发布的 turorialspoint 链接上:
http://www.tutorialspoint.com/http/http_requests.htm
Run Code Online (Sandbox Code Playgroud)
这转化为
GET /http/http_requests.htm HTTP/1.1
Host: www.tutorialspoint.com
Run Code Online (Sandbox Code Playgroud)
如果没有特定文件,则 url 将为 http://www.tutorialspoint.com/. 这转化为:
GET / HTTP/1.1
Host: www.tutorialspoint.com
Run Code Online (Sandbox Code Playgroud)
Web 服务器配置有所谓的index文件或default文件。这是在没有请求特定文件名时从目录提供的文件。通常这是index.html或default.htm或index.php,或这些的倍数,依次尝试直到找到一个。