最後更新: 2024-09-09
介紹
1xx: Informational - Request received, continuing process
2xx: Success - The action was successfully received, understood, and accepted
3xx: Redirection - Further action must be taken in order to complete the request
4xx: Client Error - The request contains bad syntax or cannot be fulfilled
5xx: Server Error - The server failed to fulfill an apparently valid request
目錄
2XX
- 200 OK
- 201 Created
- 202 Accepted
- 203 Non-Authoritative Information (since HTTP/1.1)
- 204 No Content
- 205 Reset Content
- 206 Partial Content
- 207 Multi-Status (WebDAV; RFC 4918)
- 208 Already Reported (WebDAV; RFC 5842)
- 226 IM Used (RFC 3229)
HTTP 301/302
An HTTP response with this status code will additionally provide a URL in the header field "Location"
curl -I http://mydomain
HTTP/1.1 301 Moved Permanently Date: Thu, 28 Jun 2018 03:30:23 GMT Server: Apache Location: https://mydomain/ Content-Type: text/html; charset=iso-8859-1
HTTP 301 # Permanently
The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS.
i.e. http -> https
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
HTTP 302 # Temporarily
The HTTP/1.0 specification (RFC 1945) initially defined this code, and gives it the description phrase "Moved Temporarily".
Login 相當關 (401)
- 401 Unauthorized # lacks valid authentication credentials for the requested resource
The server responds with a 401 message and a WWW-Authenticate header indicating that the request must be authenticated
401 vs 403
403 is returned when a request contains valid credentials,
but the client does not have permissions to perform a certain action.
403.4
它是一個 IIS 上的 status code 來, 代表 "Require SSL"
SSL Settins > Require SSL
304 Not Modified
Server log
IP - - [07/Sep/2024:01:00:00 +0800] "GET /files/file.pdf HTTP/1.1" 304 -
It indicates that there is no need to retransmit the requested resources.
when the request is a conditional GET or HEAD request with an If-None-Match(etag) or an If-Modified-Since(date) header.
The response would be 200 OK with the current version of the resource
if the resource had been updated after the timestamp in the If-Modified-Since header.
(Instead, we get a 304 response that includes ETag, Age and Expires headers)
206 - Partial Content
Server log
IP - - [07/Sep/2024:01:00:00 +0800] "GET /files/file.pdf HTTP/1.1" 200 13028404
It is sent in response to a range request.
The response body contains the requested ranges of data as specified in the Range header of the request.
GET
Range: bytes=21010-
Response
Content-Range: bytes 21010-47021/47022
If several ranges are requested, the Content-Type is set to multipart/byteranges,
and each fragment covers one range, with its own Content-Range and Content-Type headers describing it.
GET
Range: bytes=234-639,4590-7999
Response
Content-Type: multipart/byteranges; boundary=String_separator