HTTP in layman's personal summary

Source: Internet
Author: User

HTTP follows the Request/response model

Basic flow: A Web browser sends a request to a Web server, the Web server processes the request and responds to the Web browser

Specific steps:

1. Establishing a TCP connection

A Web browser establishes a connection over a network (the Internet, also known as a TCP/IP network) and a Web server.

Lower level protocols are established before higher layer protocols are made (HTTP is a higher-level application-layer protocol than TCP)

The typical TCP port is 80

2. Web browser sends request command to Web server

3. Web browser Send header information

Sends another message to the Web server in the form of a header, and then sends a blank line that notifies the server to end the sending of the header file

4. Web server response

such as: http/1.1 OK

http/1.1 is the protocol version number 200 is the answer status code

5, the Web server sends the answer header information

The server sends the user a few requested documents about its own data with the answer

6. The Web server wants the browser to send data

Send header message It sends a blank line to indicate that the header message is sent to this end

7. Close the TCP connection

The Web server is sent to the Web browser to close

If joining CONNECTION:KEEP-ALIVETCP will remain open, keeping the connection state can save time and network bandwidth


Request Information 3 part:

    1. Request method /URL Protocol / version

    2. Request Header

    3. Request Body

Example:

The following is an example of an HTTP request:

GET/sample.jsphttp/1.1 (1)

accept:image/gif.image/jpeg,*/*

Accept-language:zh-cn

Connection:keep-alive

Host:localhost

user-agent:mozila/4.0 (compatible; MSIE5.01; Window NT5.0)

Accept-encoding:gzip,deflate (2)

/* Indicates the end of the blank line */

username=jinqiao&password=1234 (3)


Summarize:

The client sends a full request (Request header + request body) to the server to receive this information and to return a response packet HTTP reply after processing is completed, then the connection is closed;

The client sends the request to send the request line and the request body all at once;

The browser returns the DNS resolution based on the URL you entered in the Address bar;

The server uses common Apache+tomato for processing, Apache is used to receive HTTP responses, and then requests to tomato for processing;

To establish a TCP connection is after the address bar entered the address after hitting enter, the browser has a DNS resolution process, the domain name to IP and then the browser based on the IP plus the default 80 port to establish a good TCP connection;

The information header of the HTTP request \ r \ n and the package are sent together.




HTTP in layman's personal summary

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.