http brief summary

Brief introduction

HTTP protocol (HyperText Transfer Protocol, Hypertext Transfer Protocol) is the most widely used on the Internet A network transport protocol, all WWW documents must comply with this standard.

HTTP is used to transfer a data (HTML files, image files, query results, etc.) based on TCP / IP communication protocol.

HTTP works

HTTP protocol works on the client - server architecture on. Browser as an HTTP client URL that is WEB server sends all requests to the server via HTTP.

There are Web servers: Apache server, IIS server (Internet Information Services) and so on.

Web server according to the received request, transmits the response information to the client.

The default HTTP port number is 80, but you can also be changed to 8080 or other ports.

HTTP Three things to note:

  • HTTP is a connectionless: Meaning No limitation is attached only one request per connection. After the server processes client requests and receives the customer's response, i.e., disconnected. In this way it can save transmission time.
  • HTTP is an independent media: This means that, as long as the client and the server knows how to handle the data content of any type of data can be sent via HTTP. The client and server specify the appropriate MIME-type content type.
  • HTTP is a stateless: HTTP protocol is stateless protocol. No state is no protocol for transaction processing and memory. If the lack of state means that the subsequent processing required in front of the information, it must be retransmitted, which may result in the amount of data transmitted for each connection is increased. On the other hand, when it does not require previous information in response to a faster server.

HTTP message structure

HTTP uses uniform resource identifier (Uniform Resource Identifiers, URI) to transmit data and establish a connection.

Once the connection is established, data on a similar message format used by the Internet Mail [RFC5322] and Multipurpose Internet Mail Extensions (MIME) [RFC2045] is transmitted.

  • Client request message: request line (request line), the request header (header), a blank line and request data
  • HTTP response also consists of four parts, namely: a status line, message header, and response body blank line.

The method of HTTP request

HTTP1.0 request defines three methods: GET, POST, and HEAD method.

HTTP1.1 six new request methods: OPTIONS, PUT, PATCH, DELETE, TRACE, and CONNECT method.

Common HTTP status codes:

  • 200-- request was successful
  • 301-- resources (web pages, etc.) is permanently transferred to another URL
  • 404 - resources (web pages, etc.) requested does not exist
  • 500 - Internal Server Error

HTTP status code classification

  • 1 ** information server receives the request, the requester needs to continue operation
  • 2 ** successful operation has been successfully received and processed
  • 3 ** redirection, further action is required to complete the request
  • 4 ** client error, the request contains a syntax error or could not fulfill the request
  • 5 ** Server Error The server error has occurred during the processing of the request

Guess you like

Origin www.cnblogs.com/caizhanjin/p/11276235.html