White can understand the HTTP protocol [analysis]

A, HTTP Profile

Hyper Text Transfer Protocol

1. What is hypertext (HyperText)?

Containing text hyperlinks (Link) mark and a variety of multimedia elements (Markup) of. These hypertext documents linked to each other to form a network (Web), is also known as web page (Web Page). These links using a URL. The most common hypertext format HTML HTML.

2. What is the URL?

URL or Uniform Resource Locator (Uniform Resource Locator), a document for a unique identifier World Wide Web. The URL protocol, host and port (default is 80) and the file name of three parts.
Here Insert Picture Description

3. What is the Hypertext Transfer Protocol HTTP?

  • HTTP protocol, Hypertext Transfer Protocol (Hypertext transfer protocol). Is a detailed lays down the rules of mutual communication between the browser and the World Wide Web (WWW = World Wide Web) server, file transfer data transmission protocol of the World Wide Web via the Internet.
  • HTTP is a stateless protocol, the working protocol TCP / IP model application layer. HTTP protocol is usually carried over the TCP protocol, if added between TCP and http SSL or TLS is what we say HTTPS.
  • The default HTTP port number is 80, HTTPS port number is 443,
  • No stateless HTTP connection, here solve this problem Cookie (Another solution is Session)Here Insert Picture Description

Two, HTTP works

1. Workflow

Click URL http://blog.tianyao.site/ process to display the page
1.DNS resolution: the URL domain names into IP addresses
2.TCP connection: TCP three-way handshake to establish TPC connection (port 80)
3. Send an HTTP request : GET requests by the browser / index.html
4. server processes the request, sends back index file browser request,
5. disconnect: TCP four wave
6. the browser parses the display contents of index.html.
Here Insert Picture Description

2. The connection and stateless

  • Non-persistent connection :
    the browser in every request for a web document, you immediately create a new connection, file transfer is completed, immediately release the connection, http1.0 and http0.9 often it used in this way
  • Persistent connection :
  • After sending server does not respond immediately release the connection, the browser can use the connection to continue to access other documents connected retention time is determined by both parties
  • Statelessness :
    the server does not record whether the client is visited, HTTP stateless server simplifies the design, easier to support high-concurrency

3. packet capture analysis

1.DNS Analysis: The URL domain names into IP addresses
Here Insert Picture Description

2.TCP connection: TCP three-way handshake to establish TPC connection (port 80)
Here Insert Picture Description

3. HTTP request: GET request through the browser / index.html
Here Insert Picture Description
4. server processes the request, sends back index file browser request,
Here Insert Picture Description
5. Disconnect: TCP four wave
6. The display browser parses the index.html Content.

Three, HTTP packet structure

1.HTTP request method

method meaning
GET Request information specified page
HEAD Similar to the GET request, but the response is not returned in the specific content, for obtaining the header
POST Submit data processing request to the designated resource data is contained in the request body.
PUT Data from the client to the server transmission, replace the specified document
DELETE Delete the server specified page
CONNECT Agency services
OPTION View the server's performance allowed
TRACE Request for testing, requires the server to return the received
PATCH Supplementary PUT method, known local resource update

2.HTTP status code

classification Category Description Examples
1** Notification information The server is processing the request 100 =
2** Successful operation 200 = request succeeded
3** Redirect = Position of the permanent change page 301; page = 302 temporarily changing position
4** Customer Error 403 = Disable pages; 404 = Page Not Found
5** Server Error = 500 Internal Server Error; try again later = 503

3.HTTP head

Here Insert Picture Description

Four, HTTP header key fields

1.User-Agent field

Browser Identification (operating system identity; the level of encryption identifier; browser rendering engine identifies language version information
Here Insert Picture Description

2.Server field

Web services software release includes requests to the server
Here Insert Picture Description

3.Referer field

WEB server browser to indicate that he is from what page / URL obtain / click the current request URL / URL.

4.location field

The server tells the browser tries to access an object has been moved to another location, and head to the specified location to pick up. Http popular with the cast to https,

5.cookie field

Will use the cookie, concentrates on the

Published 78 original articles · won praise 580 · views 60000 +

Guess you like

Origin blog.csdn.net/weixin_42767604/article/details/105364847