xxleyi / learning_list

聚集自己的学习笔记
11 stars 3 forks source link

An overview of HTTP From MDN #87

Open xxleyi opened 5 years ago

xxleyi commented 5 years ago

An overview of HTTP - HTTP | MDN

MDN 上的文档还是很棒的。

xxleyi commented 5 years ago

image image image

xxleyi commented 5 years ago

Client: the user-agent: The browser is always the entity initiating the request.

The Web server: A server presents only as a single machine virtually. With HTTP/1.1 and the Host header, they may even share the same IP address.

Proxies:

xxleyi commented 5 years ago

Basic aspects of HTTP

HTTP is simple: HTTP messages are human readable.

HTTP is extensible: New HTTP headers can be introduced by a simple agreement between a client and a server.

HTTP is stateless, but not sessionless: While the core of HTTP itself is stateless, HTTP cookies allow the use of stateful sessions.

HTTP and connections: Keep-Alive and call a better transport protocol.

xxleyi commented 5 years ago

What can be controlled by HTTP

xxleyi commented 5 years ago

HTTP flow

If HTTP pipelining is activated, several requests can be sent without waiting for the first response to be fully received. HTTP pipelining has proven difficult to implement in existing networks, where old pieces of software coexist with modern versions. HTTP pipelining has been superseded in HTTP/2 with more robust multiplexing requests within a frame.

xxleyi commented 5 years ago

HTTP Messages

image image

xxleyi commented 5 years ago

APIs based on HTTP

  1. The most commonly used API based on top of HTTP is the XMLHttpRequest API, which can be used to exchange data between a user agent and a server.

  2. The modern Fetch APIprovides the same features with a more powerful and flexible feature set.

  3. Another API, server-sent events, is a one-way service that allows a server to send events to the client, using HTTP as a transport mechanism.

Using the EventSource interface, the client opens a connection and establishes event handlers. The client browser automatically converts the messages that arrive on the HTTP stream into appropriate Event objects, delivering them to the event handlers that have been registered for the events' type if known, or to the onmessage event handler if no type-specific event handler was established.

xxleyi commented 5 years ago

Conclusion

HTTP is an extensible protocol that is easy to use. The client-server structure, combined with the ability to simply add headers, allows HTTP to advance along with the extended capabilities of the Web.

Though HTTP/2 adds some complexity, by embedding HTTP messages in frames to improve performance, the basic structure of messages has stayed the same since HTTP/1.0. Session flow remains simple, allowing it to be investigated, and debugged with a simple HTTP message monitor.