Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A complete Collection of HTTP status codes

2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

200-the server successfully returned the page 404-the requested page does not exist 503-the service is not available

1xx (temporary response)

A status code that represents a temporary response and requires the requestor to continue with the operation.

Code description

100 (continue) the requestor shall continue to make the request. The server returns this code indicating that the first part of the request has been received and is waiting for the rest.

101 (switching protocol) the requestor has asked the server to switch the protocol, and the server has confirmed and is ready to switch.

2xx (successful)

Indicates the status code that successfully processed the request.

Code description

200 (successful) the server has successfully processed the request. Typically, this means that the server provides the requested web page.

201 (created) the request was successful and the server created a new resource.

202 (accepted) the server has accepted the request, but has not yet processed it.

203 (unauthorized information) the server has successfully processed the request, but the information returned may have come from another source.

The 204 (no content) server successfully processed the request but did not return anything.

The 205 (reset content) server successfully processed the request but did not return anything.

The server successfully processed some GET requests.

3xx (redirect)

Indicates that further action is required to complete the request. Typically, these status codes are used for redirection.

Code description

300 (multiple selections) the server can perform a variety of actions for requests. The server can select an action based on the requestor (user agent), or provide a list of actions for the requestor to choose from.

The web page requested by 301 (permanent Mobile) has been permanently moved to a new location. When the server returns this response (the response to a GET or HEAD request), it automatically moves the requestor to a new location.

The 302 (temporary mobile) server currently responds to requests from web pages in different locations, but the requester should continue to use the original location for future requests.

The server returns this code when the requester should use separate GET requests for different locations to retrieve the response.

304 (unmodified) the requested web page has not been modified since the last request. When the server returns this response, the web page content is not returned.

305 (use proxy) requestors can only use agents to access the requested web page. If the server returns this response, it also indicates that the requestor should use a proxy.

The 307 (temporary redirect) server currently responds to requests from web pages in different locations, but the requester should continue to use the original location for future requests.

4xx (request error)

These status codes indicate that the request may have gone wrong, hindering the processing of the server.

Code description

400 (error request) the server does not understand the syntax of the request.

The 401 (unauthorized) request requires authentication. For web pages that need to log in, the server may return this response.

The 403 (prohibited) server rejected the request.

404 (not found) the server could not find the requested web page.

405 (method disabled) disables the method specified in the request.

406 (not accepted) cannot respond to a requested web page with the requested content feature.

407 (Agent authorization required) this status code is similar to 401 (unauthorized), but the designated requestor should authorize the use of the agent.

408 (request timeout) the server timed out while waiting for a request.

409 (conflict) the server collided while completing the request. The server must include information about the conflict in the response.

410 (deleted) if the requested resource has been permanently deleted, the server returns this response.

411 (valid length required) the server does not accept requests without valid content length header fields.

412 (prerequisites not met) the server did not meet one of the prerequisites set by the requestor in the request.

413 (the request entity is too large) the server cannot process the request because the request entity is too large to handle.

414 (the requested URI is too long) the requested URI (usually the URL) is too long for the server to process.

415 (unsupported media type) the format of the request is not supported by the request page.

416 (request range does not meet requirements) if the page cannot provide the requested scope, the server returns this status code.

417 (did not meet expectations) the server did not meet the requirements of the expectation request header field.

5xx (server error)

These status codes indicate that an internal error occurred while the server was trying to process the request. These errors may be the fault of the server itself, not the request error.

Code description

500 (server internal error) the server encountered an error and was unable to complete the request.

The 501 (not yet implemented) server does not have the ability to complete the request. For example, this code may be returned when the server does not recognize the request method.

The 502 (error gateway) server, as a gateway or proxy, received an invalid response from the upstream server.

The 503 (service unavailable) server is currently unavailable (due to overload or downtime maintenance). Usually, this is only a temporary state.

The 504 (gateway timeout) server acts as a gateway or proxy, but does not receive a request from the upstream server in time.

505 (the HTTP version is not supported) the server does not support the HTTP protocol version used in the request.

RFC 6585 was recently released, and this document describes four new HTTP status codes.

Is the HTTP protocol still changing? Yes, the HTTP protocol is evolving all the time, and new status codes are very useful for developing REST services or HTTP-based services. Here are four new status codes and whether they should be used or not.

428 Precondition Required (prerequisites required)

The prerequisite is that when the client sends a HTTP request, some preset conditions must be met if the request is to be successful.

A good example is the If-None-Match header, which is often used in GET requests. If If-None-Match is specified, the client will only re-receive the response after the ETag in the response has changed.

Another example of a prerequisite is the If-Match header, which is commonly used on PUT requests to indicate that only resources that have not been changed are updated, which is used to prevent multiple clients from overwriting the same content with each other when using HTTP services.

When the server uses the 428 Precondition Required status code, it means that the client must send the above request header to execute the request. This method provides an effective way for the server to prevent the 'lost update' problem.

429 Too Many Requests (too many requests)

This status code is useful when you need to limit the number of services requested by the client, that is, the request speed limit.

Before that, there were some similar status codes, such as' 509 Bandwidth Limit Exceeded'. Twitter uses 420 (this is not a status code defined by HTTP)

If you want to limit the number of client requests to the service, use the 429 status code with a Retry-After response header to tell the client how long it will take to request the service again.

431 Request Header Fields Too Large (request header field is too large)

In some cases, the HTTP request header sent by the client becomes very large, so the server can send 431 Request Header Fields Too Large to indicate the problem.

I'm not sure why I didn't have a 430 status code, but jumped directly from 429 to 431. I tried to search but there was no result. The only guess is that 430 Forbidden is too much like 403 Forbidden. I did it to avoid confusion, God knows!

511 Network Authentication Required (network authentication required)

This status code is interesting to me. If you are developing a HTTP server, you don't necessarily need to deal with it, but if you are writing a HTTP client, it is very important.

If you use laptops and smartphones frequently, you may notice that a large number of public WIFI services require you to accept some protocols or log in before you can use them.

This is done by blocking HTTP traffic, which is annoying when a user tries to access the network and returns a redirect and login, but that's the way it is.

Using these "intercept" clients will have some nasty side effects. There are examples of these two mentioned in RFC:

If you visit a website before logging into WIFI, the network devices will block the first request, and these devices often have their own website icon 'favicon.ico'. After logging in, you will find that the icon of the website you visit has been the icon of the WIFI login site for some time.

If the client uses a HTTP request to find the document (possibly JSON), the network will respond to a login page so that your client will parse the error and cause the client to run abnormally, which is very common in reality.

Therefore, 511 status code is proposed to solve this problem.

If you are writing a HTTP client, you'd better check the 511 status code to see if authentication is required before you can access it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report