OpenStack? HTTP protocol

Source: Internet
Author: User

Preface

Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet. All www files are subject to this standard.

HTTP is a TCP/IP communication protocol to transfer data (HTML files, image files, query results)

The HTTP protocol works on the client-server architecture. The browser sends all requests via URLs to the HTTP server, which is the Web servers, as an HTTP client. The Web server sends a response message to the client, based on the received request. (The requested data tends to be small, and the data returned is often larger.) Because the body is included in the returned data)

HTTP is stateless FTP is stateful

Why to learn the HTTP protocol

The main purpose is to facilitate the construction of the back OpenStack, because the various components in OpenStack are based on restful APIs, and the RESTful API can be understood as a URL address that is the HTTP protocol for communicating

How does a user access a file in a browser?

See

The difference between HTTP1.1 and 1.0

The 1.http/1.0 protocol uses a non-persistent connection, that is, a TCP connection transmits only one Web object under a non-persistent connection;
2.http/1.1 uses persistent connections by default (however, clients and servers of the http/1.1 protocol can be configured to use non-persistent connections).

Under Persistent connections, you do not have to establish a new connection for each Web object's delivery, and you can transfer multiple objects in one connection!

URL and URI

URL: (unifrom/universal Resource Locator) abbreviation, Uniform Resource Locator

URI: (Uniform Resource Identifier) abbreviation, the Uniform Resource Identifier (representing a standard)

URL: Protocol Name://domain: port such as http://www.cnblogs.com:80/

URI: Protocol Name://domain: Port/path such as http://www.cnblogs.com:80/index.html

Request Agreement

Request format (that is, the content format that the browser sends to the server)

http://host[:p ort][abs_path][Empty line] [request body]http: Indicates that the network resource is to be located through the HTTP protocol host: Represents a legitimate Internet host domain name or IP address port: Used to specify a port number, The server host that owns the requested resource listens to the TCP connection for that port (if port is empty, the default is 80) when the port of the server is not 80 o'clock, specify the port number Abs_path: Specifies the URI of the requested resource. Blank line: Used to separate the request body from the request body: Commonly used is get or post (get no request body, Post has request body)

The browser sends the request to the server the content is this format, if not this format server cannot interpret.

GET Request:

HTTP default request is get

Characteristics:

No request body (get does not include user-submitted information, such as user name password, such as such privacy information)

Request data must be within 1K (socket protocol specified)

The data from the GET request is exposed in the browser's address bar

Get requests common operations

The browser address bar gives the URL address directly, which is the GET request

Click on the link on the page, also a GET request

The default time to submit a form (for example, login in the front-end is the meaning of the form) is get, but it can also be set to post. It's basically post when you submit your data.

Instance

Www.zhihu.com

Response: Return body (User-acquired page)

View Request header information

Click View Source to see the source code such as

1:get request. "/" represents the page to be accessed. HTTP Protocol 1.1

2:host Access to host

3: Link Type: Long connection

4:upgrade-insecure-requests

5:user-agent:user Client Some simple information

6:accept: You can receive those page types. (text/html, XML, image, etc.)

7:accept-encoding: Character encoding (let computer literate character) here represents the compression format

8:accept-language: Supported language formats

9:cookie: A Cookie corresponds to a session

10:if-modified-since: When the client makes a request to the server again and sends this time, the server will compare to its own last-modified time, if the time is the same, then the browser will extract the cache page from the local, greatly alleviate the server performance

The above is the request process, after the end of the client request, the server will return two things (one is the response page, the other is the response header response Headers)

Viewing response header information

Click View Source to see the source code such as

1:http/1.1 OK client receives HTTP protocol, return status code (request succeeded)

2:content-type: The data type returned to the client (what type to return, and how to parse the type)

3:date: Show Date

4:SWS: Web Services used by the home page of the site

5:expires: Expiration time of cache

6:last-modified: Time of last page modification

7:content-encoding: What type of compressed response content to use

8:content-length: Page size (does not include image video, etc., including connections only)

The above is a brief introduction to the response header

General Information

1: Client-requested URL address

2: Request type

3: Status Code

4: Remote Address

POST request

Characteristics:

1: Data does not appear in the address bar

2: Data size not online

3: A request body

4: If there is Chinese in the request body, URL encoding will be used

Instance

1 <! DOCTYPE html> 2 

Testing in Pycharm

1 See test.html in the Address bar is this HTML file

2 "?" in the back of the page Represents a GET Request

If the default request is a Get method, the following results will appear when you enter the user name and password

The user name and password you just entered are printed to the address bar. This is more dangerous. However, this result does not occur if you set the POST request

Therefore, the POST request does not print the user name and password to the address bar. But the browser to help you hide it up. In the source of the page in the header information can be seen below a form Data This is the information you submitted

Referer: which page is requested from then if the Baidu click Link to here, then is referer://http:www.baidu.com; If you enter the address directly in the browser, there is no Referer value (for the anti-theft chain function)

Status code

The meaning of the status code is important to the browser, and returning different status codes has different meanings. For example, 200 indicates a successful response, 302, redirection, etc.

200: Request succeeded

3XX: redirect

4XX: Client error (401 access is denied.) 403 No access. 404 Pages Not Found, etc.)

5XX: Service-side error (500 Internal server error. 503 Service is not available. 504 Gateway Timeout, etc.)

OpenStack? HTTP protocol

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.