HTTP protocol--Request and response

Source: Internet
Author: User
Tags response code

1. Introduction

HTTP is an object-oriented protocol belonging to the application layer, which is suitable for distributed hypermedia information System because of its simple and fast way. It was proposed in 1990, after several years of use and development, has been continuously improved and expanded. Currently used in the WWW is the sixth edition of Http/1.0, http/1.1 standardization work is in progress, and Http-ng (Next Generation of HTTP) has been proposed.

The main features of the HTTP protocol can be summarized as follows:

1. Support client/server mode.

2. Simple and fast: When a customer requests a service from the server, it simply transmits the request method and path. The request method commonly has, POST. Each method specifies a different type of contact between the customer and the server. Because the HTTP protocol is simple, the HTTP server's program size is small, so the communication speed is fast.

3. Flexible: HTTP allows the transfer of any type of data object. The type being transmitted is marked by Content-type.

4. No connection: The meaning of no connection is to limit the processing of only one request per connection. When the server finishes processing the customer's request and receives the customer's answer, the connection is disconnected. In this way, the transmission time can be saved.

5. Stateless: The HTTP protocol is a stateless protocol. Stateless means that the protocol has no memory capacity for transactional processing. A lack of state means that if the previous information is required for subsequent processing, it must be re-routed, which may cause the amount of data to be transferred per connection to increase. On the other hand, it responds faster when the server does not need the previous information.

2. HTTP request and Response

2.1 HTTP request--method

GET

Request to get the resource represented by Request-uri

POST

Append new data to the resource identified by Request-uri

HEAD

Request for a response message header for a resource identified by Request-uri

PUT

The request server stores a resource and uses Request-uri as its identity

DELETE

Requesting the server to delete resources identified by Request-uri

TRACE

Request Server Loopback received request information, primarily for testing or diagnostics

2.2 HTTP request--Common response code

Status code

Describe

Client request succeeded

200

Ok

Client request succeeded

206

Partial Content

Return part of the request entity

301

Moved Permanently

Target permanent movement

60W

Found

Find Target (target is moved temporarily)

304

Not Modified

Target not modified

400

Bad Request

Client requests have syntax errors and cannot be understood by the server

403

Forbidden

The server received the request but refused to provide the service

404

Not Found

Request resource does not exist

413

Request Entity Too Large

Request entity too large

500

Internal Server Error

An unpredictable error occurred on the server that prevented the client from completing the request

502

Bad Gateway

Gateway error, which may be caused by network failure or excessive load.

504

Gateway Timeout

Connection timed out

3. Common HTTP header fields

[Plain] View Plaincopy

  1. Accept (identifies entity types that the browser can accept)
  2. Accept-charset/accept-language (character set and language)
  3. Accept-encoding (Accept encoded format gzip or Deflat)
  4. Cache-control (Cache policy. Example: Cache-control:no-cache)
  5. Pragma (callout. Example: Pragma:no-cache)
  6. Connection (connection parameter.) Example: Connection:close)
  7. Date (day. Example: DATE:MON,31DEC200104:25:57GMT)
  8. Content-type (Identifies the entity type.  For example: content-type:text/html. Mime.types file example)
  9. Transfer-encoding (transfer encoding. Chunk)
  10. Content-length (solid length)
  11. Set-cookie/cookie
  12. User-agent (Browser ID)
  13. Host (target host)
  14. Expires
  15. Last-modified
  16. Range/content-range
  17. Content-disposition
  18. Referer (reference, usually the URL of the previous visit)

4. HTTP protocol format and structure---examples

[Plain] View Plaincopy

  1. Get/index.shtml http/1.1
  2. Host:www.google.com
  3. user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; ZH-CN; rv:1.9.0.5) gecko/2008120122 firefox/3.0.5
  4. accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  5. accept-language:zh-cn,zh;q=0.5
  6. Accept-encoding:gzip,deflate
  7. accept-charset:gb2312,utf-8;q=0.7,*;q=0.7
  8. keep-alive:300
  9. Connection:keep-alive
  10. http/1.x OK
  11. Date:tue, 08:26:37 GMT
  12. server:apache/2.2.8 (Unix) php/5.2.6
  13. Accept-ranges:bytes
  14. Keep-alive:timeout=5, max=99
  15. Connection:keep-alive
  16. Transfer-encoding:chunked
  17. content-type:text/html; Charset=utf-8

HTTP protocol--Request and response

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.