Http:hypertext Transfer Protocol (Hypertext Transfer Protocol)
It is an application-layer protocol for the TCP/IP protocol that defines the process of exchanging data between a Web browser and a Web server and the format of the data itself.
version of the HTTP protocol: http/1.0, http/1.1
Basic operating mode of HTTP1.0:
The information exchange process of the client/server mode based on the HTTP protocol, which is divided into four processes, establishing the connection, sending the request information, sending the response information, and closing the connection.
The connection between the browser and the Web server is short-lived, and each connection only processes one request and response. Access to each page, the browser and the Web server to establish a separate connection.
All communications between the browser and the Web server are completely separate requests and responses.
Features of HTTP1.1:
Multiple HTTP requests and responses can be delivered on a TCP connection.
Multiple request and response processes can overlap
Added more request headers and response headers, such as host, if-unmodified-since request first
HTTP Request message:
After the client connects to the server, it requests a Web resource from the server, which is called the client sends an HTTP request to the server.
A complete HTTP request includes the following:
A request line, a number of message headers, and a request body, where some of the message headers and bodies are optional, separated by a blank line between the message header and the body content.
HTTP Response message:
An HTTP response represents the data that the server echoes back to the client.
A complete HTTP response includes the following:
A status line, a number of message headers, and a response body, where some of the message headers and bodies are optional, separated by a blank line between the message header and the body content.
Get mode
If the request method is GET mode, you can bring the data to the server in the form of the requested URL address, and multiple data are separated by &, for example: Get/mail/1.html? NAME=ABC&PASSWORD=XYZ http/1.1 Get mode features: The parameters that accompany the URL address are limited, and their data capacity usually cannot exceed 1K.
Post mode
If the request mode is post, you can send data to the server in the body content of the request, Post mode features: The amount of data transmitted is unrestricted.
Details of the HTTP response--Status line
Common status Code:
200 (normal) indicates that everything is normal and returns the normal request result
302/307 (Temporary redirect) indicates that the requested document has been temporarily moved elsewhere, and the new URL for this document is given in the location response header.
304 (unmodified) indicates that the version of the client cache is up-to-date and the client can continue to use it without requiring a server request.
404 (Not found) the resource requested by the client does not exist on the server.
500 (server internal error) The server-side program has an error
Details of HTTP request--Request Header
The Request header field is used by the client to pass additional information to the server in the request message, primarily including information such as the type of data (MIME type) that the client can accept, the compression method, the language, and the URL address of the page to which the requested hyperlink belongs.
Common Request headers:
Accept: The MIME type acceptable to the browser
Accept-charset: The browser tells the server through this header which character set it supports
Accept-encoding: The way the browser can decode data encoding, such as gzip
Accept-language: The type of language the browser wishes to use when the server is able to provide more than one language version. Can be set in the browser.
Host: Hosts and ports in the initial URL
Referer: Contains a URL where the user accesses the currently requested page from the page represented by the URL
Content-type: Content Type
if-modified-since:wed, 12:04:56 GMT Use this header to match the server's file, and if so, read the file directly from the cache.
User-agent: Browser type.
Content-length: Indicates the length of the request message body
Connection: Indicates whether a persistent connection is required. If the server sees the value here as "keep-alive", or sees the request using an HTTP 1.1 (HTTP 1.1 defaults to persistent connection Cookie: This is one of the most important request header information
Date:Date:Mon, 01:55:39 GMT Request time GMT
HTTP response Details-common response headers
The Response header field is used to pass additional information to the client
Common response Headers:
LOCATION:HTTP://WWW.IT315.ORG/INDEX.JSP indicates the location of the new resource
Server:apache Tomcat indicates the type of server
The type of encoding used by the Content-encoding:gzip server to send data
Content-length:80 tells the length of the browser body
CONTENT-LANGUAGE:ZH-CN the language of the text sent by the service
content-type:text/html; MIME type of content sent by the charset=gb2312 server
Last-modified:tue, last modified time for 18:23:51 GMT file
Refresh:1;url=http://www.it315.org indicates the client refresh rate. Unit is seconds
Content-disposition:attachment; Filename=aaa.zip instructs the client to download the file
SET-COOKIE:SS=Q0=5LB_NQ; Path=/search server-Side cookies sent
Expires:-1 Cache-control:no-cache (1.1) connection:close/keep-alive
Date:tue, Jul 18:23:51 GMT
008_02http Basic Knowledge