http learning record (from time to time update)

Http learning

Reference to the sister school seniors who recommended to choose a "graphic http" (white prostitute and did not buy books)
Indefinite time learning = - =

Dy0l

1.1 Use HTTP protocol to access web

Web using the HTTP protocol as a standard, the completion of a series of operational processes from the client to the server and so on. The Web is to establish communications over the HTTP protocol.

The birth of 1.2HTTP

http is to allow people to share knowledge and set, after a lengthy process of development. While almost no updated version of http. Being developed HTTP / 2.0 also want to have a higher coverage still need some time

1.3 network infrastructure TCP / IP

TCP/IP 是互联网相关的各类协议族的总称
TCP / IP protocol suite into four layers:
the application layer, transport layer, network layer and the data link layer.

Application layer: determine the activity level of communication when providing application services to users. Such as FTP and DNS.
Belonging to the HTTP layer.

Transport Layer: corresponding to an application layer, data transmission is provided between the two computers in a network connection. There are TCP and UDP.

Network layer (Network interconnection layer): for processing data packets flowing on the network, specifies how to reach the other side of the path by the computer, and transmits the data packets to each other.

Link layer: a hardware processing section is connected to the network.

Here Insert Picture DescriptionBelonging to a subset of HTTP TCP / IP protocol suite

1.4IP, TCP and DNS

IP: Internet Protocol

Various data packet to the other side. While an important condition to ensure the successful transfer of the IP address and MAC address. Communication between the MAC address-dependent IP, ARP protocol commonly used to resolve the address

TCP: provides reliable byte-stream service

Three-way handshake : to ensure the reliability of TCP. Three-way handshake
Of course, TPC not only rely on three-way handshake to ensure the reliability.

DNS:

Responsible for DNS, and HTTP protocol belong to the application layer. To provide domain name resolution services between IP addresses.

Relations with the various protocols HTTP 1.6 protocol

Clients enter the domain name, DNS domain name to an IP address. While HTTP request message generated, then according to the TCP protocol HTTP request packet is divided into a plurality of segments to facilitate communication. And then relay transmission according to the IP protocol. Packet obtained after the division and the server according to the TCP protocol packets recombination, followed by the request message according to the HTTP protocol processing to understand the needs of the client. And the use of the use of TCP / IP protocol again to request the results return.

1.7URL sum URI

URI is to locate resources represented by a protocol identifier scheme. Agreement means the agreement type the name of the program to access the resources used.
URL是URI的子集

A complete URI:A full URI

Day02

2.1 HTTP protocol for communication between the client and the server

Requesting access to one ends of text or images, etc. referred to as client resources, and resources in response to the called server.

2.2 reached communicate by exchanging requests and responses

Request packet by the request method, the URI request, protocol version, an optional header field and content requesting entity configuration.

2.3 HTTP is the protocol does not save state

Because HTTP to HTTP efficiency does not save the state, and in order to solve the problem of preservation, the introduction of Cookie technology.

2.4 -2.6

HTTP protocol to use resources on the Internet a URI, and by GETPOSTPUTHEADDELETEOPTIONSTRACECONNECT等方法,向请求 URI 指定的资源发送请求报文,告知服务器客户端的需求。

2.7 持久连接节省通信量

HTTP 协议的初始版本中,每进行一次 HTTP 通信就要断开一次 TCP 连接。以当年的通信情况来说,因为都是些容量很小的文本传输,所以即使 这样也没有多大问题。可随着 HTTP 的普及,文档中包含大量图片的 情况多了起来。
比如,使用浏览器浏览一个包含多张图片的 HTML 页面时,在发送 请求访问 HTML 页面资源的同时,也会请求该 HTML 页面里包含的 其他资源。因此,每次的请求都会造成无谓的 TCP 连接建立和断 开,增加通信量的开销。

为了解决此问题,HTTP1.1推出了持久连接的方法,并且在HTTP/1.1 中,所有的连接默认都是持久连接,从而有效的减少了 TCP 连接的重复建立和断开所造成的额 外开销,减轻了服务器端的负载。
Aims to establish a persistent connection to interact with multiple requests and responses after 1 TCP connection

也正是因为持久连接,催生出了管线化方式,可以不用等待相应就直接发送下一个请求。

2.8 Cookie技术

Cookie 技术通过在请求和响应报文中写入 Cookie 信 息来控制客户端的状态。
Cookie 会根据从服务器端发送的响应报文内的一个叫做 Set-Cookie 的 首部字段信息,通知客户端保存 Cookie。当下次客户端再往该服务器 发送请求时,客户端会自动在请求报文中加入 Cookie 值后发送出 去。
服务器端发现客户端发送过来的 Cookie 后,会去检查究竟是从哪一 个客户端发来的连接请求,然后对比服务器上的记录,最后得到之前 的状态信息。Cookie request in a state without

总的来说Cookie技术的诞生使得HTTP既保留了无状态协议的优点的同时又使得信息得以保存。

day03

3.1HTTP报文

HTTP 报文大致可分为报文首部和报文主体两块块。请求端(客户端)的 HTTP 报文叫做请求报文,响应端(服务器端)的叫做响应报文。 两者由最初出现的 空行(CR+LF)来划分。通常,并不一定要有报文主体。HTTP 报文的结构

请求报文及响应报文的结构

请求报文和响应报文的首部内容通常由请求行状态行首部字段组成
可能包含 HTTP 的 RFC 里未定义的首部(Cookie 等)。

3.3编码提升传输速率

HTTP 在传输数据时可以按照数据原貌直接传输,但也可以在传输过 程中通过编码提升传输速率。通过在传输时编码,能有效地处理大量 的访问请求。但是,编码的操作需要计算机来完成,因此会消耗更多 的 CPU 等资源。

压缩传输的内容编码

当发送时,为了使容量变小,HTTP 协议中有一种被称为内容编码的功能可以使实体内容上的编码格式保持实体信息原样压缩。内容编码后的实体由客户端接收并负责解码。
内容编码

分割发送的分块传输编码

在 HTTP 通信过程中,请求的编码实体资源尚未全部传输完成之前, 浏览器无法显示请求页面。在传输大容量数据时,通过把数据分割成 多块,能够让浏览器逐步显示页面。

这种功能被称之为分块传输编码(Chunked Transfer Coding)。
使用分块传输编码的实体主体会由接收的客户端负责解码,恢复到编 码前的实体主体。

HTTP/1.1 中存在一种称为传输编码(Transfer Coding)的机制,它可 以在通信时按某种编码方式传输,但只定义作用于分块传输编码中

3.4 发送多种数据的多部分对象集合

HTTP 协议中也采纳了多部分对象集合,发送的一份报文主 体内可含有多类型实体。通常是在图片或文本文件等上传时使用。

3.5 获取部分内容的范围请求

一种只请求部分范围的功能

3.6 内容协商返回最合适的内容

内容协商技术有3种类型:

服务器驱动协商(Server-driven Negotiation)

Content negotiation by the server. In request header field as a reference, at the end of the automatic processing server. But for users, the information sent by the browser as the basis for decision, it does not necessarily filter out the best content.

Client-driven negotiation (Agent-driven Negotiation)

Conduct of content negotiation by the client. Users can manually select from a list of options displayed in the browser. You can also choose to automatically carry out the above on a Web page can use JavaScript. Such as browser type or by type of OS, switch to the PC version of the page itself or Mobile version.

Transparent consultation (Transparent Negotiation)

The server and the client driving the drive combination, by the server and client are each a method for content negotiation.

Content negotiation mechanism refers to the content of the resource on the client and server-side response to negotiate, and then provided to the client the most appropriate resource. Content negotiation in the language, character set, encoding and other response resources as a reference for determination.

Released three original articles · won praise 0 · Views 116

Guess you like

Origin blog.csdn.net/WSX756164967/article/details/103975648
Recommended