An Introduction to HTTP protocol: 1 Introduction:
HTTP protocol, full name Hypertext Transfer Protocol. Chinese name Hypertext Transfer Protocol, which is an important part of the provision of WWW services, the initial purpose of these HTTP protocols is to provide a way to publish and accept HTML pages.
2 HTTP protocol version: 1 HTTP1.0 version:
Features: With the addition of the request header to the 0.9 version, can support a variety of request methods, and the multimedia object can be processed, so that the Web interface with the picture and interactive table is called possible, it requires only a short link between the browser and the server, the browser each request needs to establish a TCP connection with the server, the server completes the request after the next P, the server does not track customers, does not log requests, and supports mechanisms such as identity authentication, state management, and cache caching.
2 HTTP1.1 version
Features: Improvements from scalability, cache processing, bandwidth optimization, persistent links, host headers, error messages, message delivery, content negotiation, and more
Connection aspect: Support persistent link, one TCP can transmit multiple HTTP messages.
Request header: Added more request headers and response header messages to increase the functionality of HTTP. Host header feature allows a Web browser to use the host name header to explicitly access the server's Web site, so that you can use a Web server to configure multiple virtual Web sites on the same IP address and port.
Persistent link facet: When the value of the request header is keep-alive, the link is not interrupted, and when close, the link is closed
3 HTTP Request method
http Method |
function Description |
GET |
The client requests the specified resource information and the server returns the specified resource |
HEAD |
Only the HTTP header in the corresponding message is requested |
POST |
Submit the client's data to the server |
PUT |
Replaces the specified document content with data that is transferred from the client to the server |
DELETE |
Requesting the server to delete the resource identified by Requst-uri |
MOVE |
The request server moves the developed page to another network address |
4 HTTP Status Code 1: Introduction
A numeric code that identifies the status of the Web server's corresponding HTTP request, which is a three-digit status code that informs the Web client that the request was successful or that additional actions are required.
Status Code range |
function Description |
100-199 |
Used to specify certain actions for the client |
200-299 |
Used to identify the request was successful |
300-399 |
Used for files that have been moved, and long is included in the location header information specified in the address information |
400-499 |
Used to indicate client-side errors |
500-599 |
Errors used in server |
Common status codes and their corresponding functions
Status Code |
Description |
200-ok |
Status code returned by a successful HTTP request |
301-moved Permanently |
Permanent jump, the requested page will permanently jump to the new location set |
403-forbidden |
Prohibit access, legal, but server-side set rules |
404-not found |
The server could not find the specified page for the client request |
500-internal Server Error |
Internal server error, the server encountered unexpected situation, can not complete the client resolution |
502-bad Gateway |
Bad gateway, typically a proxy server requesting a back-end server, the backend server is unavailable, or the appropriate gateway server is not completed |
503-service unavailable |
The service is currently unavailable, and may be server overloading or downtime maintenance. Or the reverse proxy does not have a available node behind it |
504-gateway Timeout |
When a network timeout, the backend service does not complete processing requests at a specific time when the Gateway Proxy server requests the backend service |
16 status codes are defined in the HTTP1.0, and 24 new status codes are added to the HTTP1.1 photo.
2 Status Code command-line view:
5 HTTP Message 1 HTTP message classification:
Web client to server (Request message requests message)
Server returns Web client (corresponding message response message)
2 Request Message Description
Composition: Request line, request header, blank line, request message body.
Message Format | Message
Information |
Request Line |
Request Method URL Protocol version |
Request Header |
Accept:image/gif,image/jpeg |
Blank Line |
Blank no content |
Request message body |
The Get method does not request a message body, only the Post method has |
Request Message Details:
Request line: Used to describe what the client wants to do: The Request Method field, the URL field, and the HTTP protocol version field, separated by a space
Request Method |
URL Field Example |
HTTP protocol version |
GET |
/index.html |
http/1.1 |
Request Header: Consists of key-value pairs, each pair of lines, keywords and values by: Split
Request header Information |
Description |
Accept:image/gif,image/jpeg |
Media type |
ACCEPT-LANGUAGE:ZH-CN: |
Language type |
Accept-encoding:gzip,deflate |
Support compression |
user-agent:mozilla/4.0 (compatible; MSIE 6.0;windows NT;) |
Client type |
Host:www.baidu.com |
Host Name |
The longest requested headers are content-type and content-length.
Blank line: Notifies the Web server that a blank line will not have the requested header information by sending a carriage return and a line break.
Request message body:
The request message body contains the data to be sent to the Web server, the request message body does not apply to the HTTP GET method, but applies to the Post method,
3 Response Message Description:
Message Format | Message
Information |
Start line |
Protocol and version number, number status code, status information |
Response Head |
Field Name 1: Value .... |
Blank Line |
Blank no content |
Corresponding message body |
Content in various HTML formats |
Start line: Protocol version number, number status code, status condition. http/1.1 OK
Response headers: Similar to request messages, there are usually several header fields behind the starting line, each containing a name and a value, separated by a colon.
Blank line: After the last response to the header information is a blank line, by sending a carriage return and line break, notify the client empty line afternoon header information
Response message body:
Loads the data to be returned to the client, which can be either text or binary
Two HTTP Resources 1 Media type:
The Web server will place a MIME-type data format label on each object transmitted over the Web, and when the Web server corresponds to an HTTP request, a MIME type is added to each HTTP object data, and when the browser obtains the information, it is processed accordingly, depending on the MIME type.
A MIME type exists in the response header information of an HTTP response message and is a text marker that represents a primary object and a specific subtype. The middle is divided by a diagonal bar.
MIME Type |
File Type |
Text/html |
html/htm/shtml Text Type |
Text/css |
CSS text type |
Text/xml |
XML literal type |
Image/gif |
GIF image type |
Image/jpeg |
Jpef,jpg Image Type |
Application/javascript |
JS Text type |
Text/plain |
TXT text type |
Application/json |
JSON text type |
Video/mp4 |
MP4 Video Type |
Video/quicktime |
MOV video type |
video/x-flv |
FLV Video Type |
Video/x-ms-wmv |
WMV Video Type |
Video/x-msvdeo |
AVI Video Type |
To view the media types supported by the server:
2 URL Description:
URLs, all called Uniform Resource location, Uniform Resource Locator (positioned, not unique), also known as the Web address.
URL is a string used to describe information resources on the Internet, mainly used in various WWW client and server programs, URLs can be used in a unified format to describe various information resources, including files, server address and directory.
URL consists of:
1 The first part is the agreement: Http/https
2 The second part is the host Resource server IP address or domain name (port number) www.baidu.com
3 The third part is the specific address of the host resource, such as directory and file name, etc., 127.0.0.1/idex.html
Protocol |
Split Symbol |
IP address or domain name |
Split Symbol |
Resource Directory Address |
http |
:// |
Www.baidu.com |
/ |
/index.html |
3 Introduction to URIs
URI full Name Uniform Resource Identifier, Chinese translation is a Uniform resource identifier, a string that identifies an Internet resource name that uniquely identifies and locates an information resource. Each available data resource on the Internet can be located by using a Uniform resource identifier.
User Mailbox Uri
Protocol (service type) |
Split Symbol |
User name |
Split Symbol |
Domain name |
mailto |
: |
Toldboy |
@ |
etiantian.org |
4 Static Web Resources
1 static Web Page description:
Static Web resources: In the Web site design, the pure HTML page (can contain pictures, video, JS front-end Function implementation, CSS (style), etc.) is often referred to as static Web pages, static Web pages, as opposed to dynamic Web pages, refers to no background database, no program, non-interactive web pages.
2 Static webpage Resources features:
Once written, it will not change, the maintenance and update of static Web pages is relatively troublesome.
Common file resource extensions for static Web pages:
Plain Text class program or file:. HTML,. htm,. xml,. shtml,. js,. CSS, etc.
Picture class file or data document:. jpg,. gif,. PHG,. bmp,. txt,. doc,. ppt, etc.
Video class streaming media files such as. mp4,. swf,. avi,. wmv,. GLV, etc.
3 static Web page features:
1 each page has a fixed URL address. and URLs generally use the. html,. htm,. shtml and other common forms of suffixes, and the address does not contain "?" or "&" and other special symbols
2 Once the content of the website is posted on the website, the content of each page is saved on the Web server file system, regardless of whether or not there are user access.
3 Web content fixed, easy to be indexed by search engines
4. Heavy workload in maintenance.
5 The interactivity of the Web page is poor.
6 Web-page programs in the user browser to resolve, high-efficiency program resolution. Because the server-side parsing is not required, the number of concurrent servers can increase.
4 Architectural ideas about static Web pages
High concurrency, high-traffic scenarios for architecture optimization, the key link is to convert dynamic Web pages into static Web pages, rather than directly request the database and dynamic server, and the static Web content pushed to the front-end cache to provide services.
5 Dynamic Web Resource Introduction
1 Dynamic Web pages: the state corresponding to a static web page
2 Dynamic page Features:
1 page extension suffix:. asp,. aspx,. php,. JSP,. Do,. CGI, etc.
2 Web pages generally based on the database as a technical basis, greatly reducing the workload of site maintenance
3 Web site with Dynamic Web technology can achieve more functions, such as user registration, user login, online survey, voting, user management, order management, post blog and so on.
4 The Dynamic Web page is not a standalone Web page file on the server, and when the user requests a dynamic program on the server, the server resolves the programs and may return a full page content by reading the database.
5 "?" in the Dynamic Web page In the search engine contains a certain problem, the search will not be from a site database access to all pages, the program on the server side of the analysis, consumes a lot of CPU and memory, I/O resources. Access is far less efficient than static web pages, so dynamic web-to-static is a necessary architectural approach for all high-concurrency sites.
6 pseudo-Static web pages
1 Introduction: The URL of the Dynamic Web page is disguised as a static web URL address by some technology, but the user is actually accessing the Dynamic Web page, but it seems to conform to the static web address characteristics, so users and some search engine will be mistaken for static Web page
2 pseudo-static web page features
1 The surface appears to be static content, but is a URL rewrite implemented through the rewrite rule.
2 after rewriting the address more beautiful, conducive to search engine crawl, to enhance user access experience.
3 pseudo-static web page not only not improve the performance of the site, but will reduce the performance of the site. If necessary, you can convert a dynamic Web site to a static web page.
Introduction to HTTP