我想知道http是如何工作的。当您在浏览器中输入“www.youtube.com”时,会发生以下步骤。
- DNS look-up for "www.youtube.com" (suppose you get 1.1.1.1)
- Open socket to 1.1.1.1 port=80 and send a GET HTTP packet on it.
- Receive a response on that socket.
我是对还是还有其他步骤?
答案 0 :(得分:1)
你是对的,虽然没有死在语法上,但这很简单。
示例请求:(#1)使用并且必须以两个回车符和换行符(CrLf)结束
GET /uri/here?other=stuff&too HTTP/1.1
Host: host
Other: Headers, too. Such as cookies
Header: Value
回复示例:(#2)
HTTP/1.1 200 OK
Other: Headers, too. Such as cookies
Header: Value
<html>Actual HTTP payload is here, could be HTML data, downloaded file data, etc.