Common http response status code (status)

1.100-199 response information

100 Continue: server tells the browser before everything is normal, continue to please the client request, if the end of the request can be ignored;

101 Switching Protocal: For Upgrade request header information returned. It indicates that the server is switched to the specified protocol.

Upgrade HTTP1.1 upgrade mechanism is proposed, can be upgraded to other protocols.

If used, the client needs to be set as follows:

Connection: Upgrade
Upgrade: protocol-name[/protocol-version]

If you do not agree to simply ignore the server; if you agree, the response is as follows:

HTTP/1.1 101 Switching Protocols
Connection: upgrade
Upgrade: protocol-name[/protocol-version]

For example: 1) Upgrade WebSocket

The client requests as follows:

GET ws://example.com/ HTTP/1.1
Connection: Upgrade
Upgrade: websocket
Origin: http://example.com
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: d4egt7snxxxxxx2WcaMQlA==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

If you agree to the server, the response is as follows:

HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Accept: gczJQPmQ4Ixxxxxx6pZO8U7UbZs=

2) Upgrading to http2

 The client requests as follows:

GET / HTTP/1.1
Host: example.com
Connection: Upgrade, HTTP2-Settings
Upgrade: h2c // h2c是http2的名称
HTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload>

If you agree to the server, the response is as follows:

HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: h2c

Early Hints 103 : This status code is mainly used for Link use with the first link, to allow the user agent server is still ready to start the pre-loading of resources in response

2.200-299 successful response

The OK 200 : Request successful

201 Created: commonly used in POST, PUT request that the request has been successful, and created a new resource. And in response to the return path body.

202 Accepted: request has been received, but no response is not returned an asynchronous request later results. This status code applies to wait for other processes or batch processing of the scene.

No-Authoritative Information 203 : show meta-information response is returned (meta-infomation) and the first server in a different, but from a local or a third party.

Mainly used for mirroring and backup other resources. In addition to the previous case, the preferred or 200.

No Content 204 : request did not return data, but the header information helpful. User agent (browser) will update the header information cached.

The Reset Content 205 : tells the user agent (browser) to reset the document sent the request.

Partical the Content 206 : When the status code returned to the client using the Range request header, the data portion of the request.

Rank explain: User Agent: Instead of running the software user, such as a web browser or mail reader.

3.300-399 redirect message

Multiple Choice 300 : return a plurality of responses, or require the user to select the browser;

Moved Permanently 301 : URL requested resource is permanently changed, the new URL is in the Location response.

The browser to the new URL re-request resources, because some clients will request method method into GET. Therefore, the status code and GET HEAD method is recommended for use.

Search engines will be updated to address the resource link (SEO in the 'link-judge' is sent to the new URL).

Found 302 : URL of the requested resource is temporarily modified to provide the URL Location. Possible future there will be new changes.

The browser will re-request the resource according to the new URL. Some clients will change the method method GET, recommended for GET and HEAD methods.

Search engines will not change the URL to the resource.

See Other 303 : service by returning the response data to guide the client to another URL access to resources through GET method.

POST or PUT request is typically used to return results, redirect to the page or information suggesting progress display page.

The method redirects a GET method.

Not Modified 304 : No change. Without re-transmission resource requested by the client. This is a resource to the cache implicit redirection.

Scenario occurs: 1) the security request method (e.g., GET, HEAD request)

2) Conditions of use request and If-None-Match or If-Modified-Since header of the request

If you want to use the 200 status code 304 to achieve the same effect, the need for additional request header: Cache-Control, Content-Location, Date, ETag, Expires, Vary

307 Temporary Redirect: temporary redirection. And 302 substantially identical.

The only difference is that this status code is strictly forbidden to modify the original browser requests a resource request way new URL and request body.

That the original use POST, or to use the POST.

If you want to use the PUT method to modify a resource is not on the server, you can use 303 status code

If you want to change a POST method GET, use 303.

Permanent Redirect 308 : permanent redirect. And basically the same as 301. But the way is strictly prohibited modification request and the request body.

4. 400-499 client error response

Bad Request 400 : problem with grammar request, the server does not recognize.

Unauthorized 401 : The client does not authorize the request. The lack of effective authentication credentials, the general might not have landed. After landing usually solve the problem.

Forbidden 403 : server refuses to respond. Insufficient permissions.

Not Found 404 : Invalid URL or URL is valid, but no resources.

Not the Allowed Method 405 : mode request Method allowed. But the GET and HEAD subject to compulsory way, can not return this status code.

Not Acceptable 406 : server resource type does not meet the requirements.

The Authorization the Required Proxy 407 : Proxy authentication required.

408 Request Timeout connect to the server will not be used in closed: Response header will Connection: close.

426 Upgrade Required:  tell the client needs to be upgraded communication protocol.

The error response to the server 500-599

Internal Server Error 500 : Internal server error was not caught.

Of Bad Gateway 502 : When used as a gateway server, the server received an invalid response is returned upstream.

Service Unavailable Papers with 503 : unable to serve. Generally occurs due to maintenance downtime or service overload.

General will be accompanied by a return response header Retry-After: state the estimated time to restore service.

Gateway Timeout 504 : Gateway Timeout. As a gateway or proxy server and can not get the response back to the client from the upstream server.

Http Version Not Supported 505 : http requests sent by the server version is not supported. If the request sent through http2, the server does not support http2.0, the status code is returned.

 

Guess you like

Origin www.cnblogs.com/lyraLee/p/11588417.html