You need to know about HTTP Status Code

You need to know about HTTP Status Code

Intro

Now before and after the end of the separation of the development model more and more popular, the back end is responsible for developing the corresponding API, only the tip need
to focus on data display and front-end logic to the front page.

For the separation of the front and rear ends of this development model, I personally prefer, because it allows more professional people to do more professional things, focus on doing the back-end API development and design, focus on the front display data, style pages .

So that the front and rear ends of the need to reach some consensus on certain information, such as the commonly used HTTP method, commonly used HTTP status codes

HTTP Method is simple, our usual habits are as follows:

General inquiries We will use the GET method,
create a new record using the POST method
to update existing data using the PUT method
update existing data portion of the property using the PATCH method
to delete the existing data using the DELETE method

Here to explain in detail the common HTTP status codes

1xx

1xx status codes generally intermediate state of a request, typically information presentation request negotiate

100 the Continue, the request has not been completed, should continue to request

101 Switching Protocol, protocol conversion, will encounter when using Web Socket, here is an example, there will be a response to Connection: Upgradethe request header, Upgradethe protocol specifies the name to be used

websocket demo

2xx

2xx successful request processing generally indicates

200 the OK, the request processing success

201 the Created, request processing was successful, and the new resource has been created

202 Accepted, the request has been accepted and is being processed, the processing has not been completed

204 No Content, the response is empty, a return in asp.net core in Json(null)time will be the result of a NoContent

3xx

3xx redirect generally expressed

301 Moved Permanently permanent redirect

302 Found temporary redirect

307 the Temporary temporary redirection request the Redirect

308 Permanent Permanent redirection request the Redirect

The difference between these redirection:
301, 302 only supports GET requests, if it is a POST request, the redirect will use GET request data will be lost and the Body

307, 308 support the POST request, POST redirected when the original request will bring the body and then request a new address, body data is not lost

302, 307 is a temporary redirect,
301,308 is a permanent redirect, allow caching, the browser can cache

304 Not Modified, resource modification does not occur, you can use the browser directly to the local cache

This is the response code to an If-Modified-Since or If-None-Match header, where the URL has not been modified since the specified date.

4xx

4xx error generally represents a client request

400 BadRequest A, Bad Request, generally used to indicate an abnormal parameter request, a parameter such a request can not be empty, but the actual request is empty

401 Unauthorized, unlicensed resources require authorization or login, and users are not logged in or do not provide the required access Token etc.

403 Forbidden, Forbidden, current user does not have permission to access resources, such as user needs Admin role, but this role is not requested by the user

404 NotFound, did not find the resources, the resource does not exist

405 Method, Not the Allowed, Method not allowed to call, resources are not supported request methods, such as resources permit only GET request, but the actual request using the POST or DELETE methods

406 Not Acceptable, requested resource client does not support processing, such as the client wants to get a response xml, but the server only supports JSON response

408 the Request the Timeout, the timeout process request

409 Conflict, request a resource conflict often occurs when updating the resource information PUT occur, such as specifying ETAG resources of updates, but when PUT request, ETAG resources has changed

410 Gone, requested resource is no longer available on the source server

411 the Length the Required, the request needs to carry Content-Lengtha request header

412 Precondition the Failed, preflight request fails, the request parameter does not meet certain conditions

The pre condition given in the request evaluated to false by the server.

413 Payload Too Large, too large parameter request, the request body is too large, the processing server rejects

414 the URI Too Long, the URI address of the request is too long, the processing server rejects

415 Unsupported Media the Type, media type not supported or unsupported encoding process such as a server only supports JSON request, but the request is in xml format

The 415 (Unsupported Media Type) status code indicates that the
origin server is refusing to service the request because the payload
is in a format not supported by this method on the target resource.
The format problem might be due to the request's indicated
Content-Type or Content-Encoding, or as a result of inspecting the
data directly.

5xx

5xx server error generally indicates

500 Internal Server Error, internal server error

501 Not Implemented The server does not support the need for processing requests, such as picture compression processing

502 of Bad Gateway reverse proxy or gateway server processing the request can not be found

503 Service Unavailable Papers with service unavailable

504 Gateway Timeout Gateway Timeout

505 HTTP Version Not Supported, does not support the HTTP version, the server does not support or refuse to deal with this version of the HTTP request

Reference

Guess you like

Origin www.cnblogs.com/weihanli/p/http-status-code-you-need-know.html
Recommended