Home  >  Article  >  Web Front-end  >  HTTP methods, status codes and components

HTTP methods, status codes and components

大家讲道理
大家讲道理Original
2017-05-28 10:53:091625browse

HttpHypertext Transfer Protocol

HTTP protocol (HyperText Transfer Protocol, Hypertext Transfer Protocol) is used to transfer files from the WWW A transfer protocol used by servers to transmit hypertext to local browsers. It can make the browser more efficient and reduce network transmission. It not only ensures that the computer transmits hypertext documents correctly and quickly, but also determines which part of the document is transmitted and which part of the content is displayed first (such as text before graphics), etc.

The information used for http protocol interaction is called a http message. The http message from the requesting end (client) is called a request message, and the

http

message from the responding end (server) is called a response message. The request message consists of request method

, request

URI, protocol version, header field (optional), content entity (optional) The response message consists of protocol version, status code

, reason phrase, header field (optional), and entity body

In each message, the request URI, protocol version, status code, reason phrase, header field belongs to the message header, then a blank line, and the rest is the message body.

There are 4 types of header fields: request header field, response header field, general header field, entity header field, general header and entity header are the request message and Both response messages have them, while request headers are only available in request messages, and response headers are only available in response messages.

Message is the basic unit in http communication, consisting of 8 bits Composed of byte stream, transmitted through http communication.

The entity is transmitted as the payload data (supplementary item) of the request and response, and its content consists of the entity header and the entity body

Generally, the message body is equal to the entity body . Only when the encoding operation is performed during transmission and the content of the entity body changes, will it be inconsistent with the message body.

http1.0 and http1.1Supported methods

##PUTTransfer files1.0,1.1##HEAD##DELETE(##CONNECTRequires tunneling protocol to connect to proxyLINKUNLINK

Method

Description

Support httpProtocol version

##GET

Get the resource identified by URI

1.0,1.1

##POST

##Transmission Entity Body

1.0,1.1

(

Without verification mechanism)

Get the message header

1.0,1.1

##Delete

file

without verification Mechanism)##1.0,1.1

OPTIONS

##Ask for support methods

1.1

TRACE

Trace path

##1.1

##1.1

Establish connections with resources

1.0

Disconnect link relationship

##1.0

##http

Status code

##Status code

##RedirectionClient Error(Client error status code)##5XXServer Error(Server error status code)Server processing request error

Category

Reason Phrase

1XX

Informational

(Informational status code)

The received request is being processed

##2XX

Success

(success status code)

The request has been processed normally.

##3XX

(Redirect status code)

Additional operations required to complete the request

4XX

The server cannot process the request

Commonly used status codes in

14

##302 FoundURI303 See Other304 Not Modified (the server-side resource is changed, and the client's unexpired resource can be directly used. Body part) indicates that access to the requested resource was denied by the server. No permission to access indicates the server The requested resource cannot be found, that is, there is no such resource Indicates that an error occurred on the server side when executing the request. It may also be that the means The server is temporarily overloaded or is undergoing downtime for maintenance, and is now unable to process requests

httpCommon header field

##200 OK

Indicates that the request from the client is processed normally on the server side

204 No Content

means that the request received by the server has been processed successfully, but the response message returned does not contain the entity body part

206 Partial Content

Indicates that the client made a range request and the server successfully executed it Partial GETRequest

##301 Moved Permaently

A permanent redirect, indicating that the requested resource has been assigned a new

URI and that the # that the resource now refers to should be used in the future. ##URI

Temporary redirection means that the requested resource has been assigned a new

, and we hope that the user can use the new URI to access ## this time.

indicates that the request corresponds to There is another

URI
for the resource. You should use the

GET method to obtain the requested resource

## indicates that the client sends conditions When requesting, the server allows the request to access the resource, but if the request does not meet the conditions, it will directly return 304 Not Modified

307 Temporary Redirect

Temporary redirection, has the same meaning as 302

#400 Bad Request

indicates that there is a syntax error in the request message. The server cannot recognize the request

401 Unauthorized

## means The request sent needs to pass the authentication information of

http authentication. If a request has been made before, it means that the user authentication failed

##403 Forbidden

404 Not Found

500 Internal Server Error

web

application has a

bug
or some temporary Fault

503 Service Unavailable

##ConnectionManage hop-by-hop headers and persistent connectionsPragmaTrailerTransfer-EncodingUpgradeVia

Common header field name

Description

##Cache -Control

##Control the

behavior of cache

Date

##Date and time when the message was created

##Message command

List of headers at the end of the message

Specify the transfer encoding method of the message body

Upgrade to other protocols and check whether higher version protocols can be used for communication

##Related information about the proxy server, tracking the client and server The transmission path between request and response messages

Warning

Error notifications, usually inform users of some warnings about cache-related issues

http1.1 Warning code (Warning has seven types)

##113Heuristic expiration(24199))

Warning code

Warning content

Description

110

Response is stale( Response has expired)

The proxy returns expired resources

##111

Revalidation failed(Revalidation failed)

The agent failed to verify the validity of the resource (the server cannot be reached, etc.)

112

Disconnection operation( Disconnect operation)

# #Agent and Internet link are deliberately cut off

Heuristic expiration

)

##The response period exceeds

hours (when the effective cache setting time is greater than 24 hours)

##Miscellaneous warning(

Miscellaneous warning
)

Any warning content

##214

Tansformation applied(Transformation used

The agent encodes the content or media type etc.

299

Miscellaneous persistent warning(persistent miscellaneous warning

Any warning content

httpRequest header field

##Accept-Prioritized languages, the natural languages ​​that the user agent can handle and the relative priority of the set of natural languagesAuthorizationWebExpectExpect specific behavior from the serverFromUser’s email addressHostThe server where the requested resource is located (host name and port number)If-MatchCompares with the entity tag (##If -Modefied-SinceIf-Modefied-Since ##If-None-MatchRange when it is not updated. If the

Request header field

Description

##Accept

The media types that the user agent can handle and the relative priority of the media types

Accept-Charset

Preferred Character set, the character set supported by the user agent And relative priority

##Accept-Encoding

takes precedence Content encoding, user agent supported content encoding and priority order

Lang

uage

Authentication information

ETag

), if If they are the same, execute the request, otherwise return 412status code

If

field value is earlier than the resource's update time, you want to process the request, otherwise return 304status code

Compare entity tags (the opposite of

If-Match
)

##If-

Resources Send a range request for entity Byte

If-Range field value is consistent with the ETag value or time of the requested resource, it will be processed as a range request, otherwise it will be returned All resources##If-Unmodified-Since

Compare the update time of resources (contrary to If-Modified-Since

)

##Max-Forwards

Maximum transmission hop-by-hop number (specifies the maximum number of servers that can be passed through in decimal form)

Proxy-Authorization

The proxy server requires the client’s authentication information

Range

Byte range request for entity

Referer

To the original getter of URI in the request (the URI of the requested original resource)

##TE

Inform the server that the client can The transfer encoding method and relative priority of processing responses

User-Agent

httpClient program information

## http

Response header field

##DescriptionAccept-RangesAccept-Ranges Byte range requestAgeResource creation process The time, in seconds ##ETagLocationURI##Proxy-AuthenticateInformation of the server
Response header field

Resource The matching information can inform the client of the entity identification

Redirect the client to the specified

Authentication information from the proxy server to the client

##Retry-After

Requirements for the timing of reinitiating the request

Server

http

Installation

##Vary

Proxy server cached management information

WWW-Authenicate

Server authentication information for the client

httpEntity header field

of the corresponding resource

Entity header field

Description

##Allow

httpMethods supported by resources

Content-Encoding

Encoding method applicable to entities

Content-Language

The natural language of entities

Content-Length

The size of the entity (in bytes)

Content-Location

#Replace the URI

Content-MD5

##Entity body message

Summary

Content-Range

The position of the entity body Scope

Content-Type

Media of the entity body Type

Expires

The date and time when the entity body expires

Last-Modified

The date the resource was last modified time

The above is the detailed content of HTTP methods, status codes and components. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn