What does HTTP look like?

丶灬走出姿态 提交于 2019-12-07 10:58:53

问题


I've been working a lot with HTTP related things - HTTP requests, HTTP responses, HTTP methods etc., but I'm not really sure I understand what the protocol itself looks like. Is it a document like a specification?


回答1:


Is it a document like a specification?

Yes, HTTP is a protocol over TCP/IP defined in the following specification: http://www.w3.org/Protocols/rfc2616/rfc2616.html

This protocol is for example implemented by web servers and client browsers.




回答2:


Hyper Text Transfer Protocol (HTTP) provides a pattern to interact with Resources (e.g. webpages on a webserver). Essentially it boils down to a Request (typically from a browser) and a Response (typically from a webserver).

The request highlighted red above identifies an action verb such as GET, POST, DELETE, or PUT (there are others verbs too) and a resource (URI/URL) to preform the action on. The request above depicts a browser request to view the wikipedia main page.

The server then responds to the request with the blue and green sections above; they represent the response header and the response body. The response header contains a lot of optional information about the server but the important fields are the status code (200 OK), the content length (54218) and the content type (text/html).

Since the content type is html the browser will try to render the html inside the response body. If the content type were something else such as a word doc then the browser would probably open a save dialog box. There are a plethora of content types that the body could represent, but not all browsers support each of the content types.



来源:https://stackoverflow.com/questions/7284510/what-does-http-look-like

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!