How HTTP Works

Source: Internet
Author: User

 HTTP working process

< Span style= "Font-family:calibri" >http protocol definition < Span style= "Font-family:calibri" >web client how to get from web server request web web page to the client. http Protocol adopted request / Response model.

The client sends a request message to the server. The request message includes the requested method,URL, protocol version number, request header, and request data.

The server responds with a status line. The content of the response includes the version number of the protocol, the success or error code, the server information, the response header, and the response data. The following figure illustrates such a request / response model.

Below is HTTP Request / steps to respond:

( 1 ) client connects to Web Server

a HTTP client. Typically a browser, with the Webserver HTTPport (default feeling ) to establish a TCP socket connection. For example,http://www.oakcms.cn.

( 2 ) Send HTTP Request

through TCP socket, client to Web the server sends a request message for a text that consists of a request line, a request header, a blank line, and a request data 4 part of the composition.

( 3 ) The server accepts the request and returns HTTP Response

Web the server resolves the request and locates the requested resource.

Server writes a copy of the resource to the TCP socket. Read by the client.

A response consists of a status line, a response header, a blank line, and a 4 portion of the response data .

( 4 ) Release connection tcp connect

< Span style= "Font-family:calibri" >web server active close tcp socket, releasing tcp connection. Client passive close tcp socket, releasing tcp connection.

( 5 ) client browser parsing HTML content

The client browser parses the status line first to see the status code indicating whether the request was successful.

Each response header is then parsed, and the response header informs the following character sets for several bytes of HTML Documents and documents. The client browser reads the response data HTML, formats It according to the syntax of the HTML, and displays it in the browser form.

The stateless nature of the HTTP protocol

HTTP the Protocol is stateless ( Stateless ).

That is, when the same client visits a page on the same server for the second time, the server cannot know that the client was previously interviewed and the server was unable to distinguish between different clients.

HTTP 's stateless features simplify the design of the server, making the server easier to support a large number of concurrent HTTP request.

Persistent Connections

HTTP1.0 using a non-persistent connection, the client must establish and maintain a new connection for each object to be requested. Because multiple objects may exist on the same page, non-persistent connections can make a page download very slow. And such a short connection adds to the burden of network transmission. HTTP1.1 introduces a persistent connection, agreeing to multiple data requests and responses in the same connection. In the case of a persistent connection, the server does not close the TCP connection after the response is sent , and the client can continue to request additional objects through this connection.

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

How HTTP Works

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.