Request Responses¶
OBS returns an HTTP response after receiving and processing a request. A response contains a status line, response headers, and an optional response body.
Response Syntax¶
Status Line: HTTP-Version Status-Code Reason-Phrase
Response Headers
<Conditional Response Body>
Status Line¶
The first line of an HTTP response is a status line consisting of space-separated elements. Table 1 describes the elements in a status line.
Element | Description |
---|---|
HTTP-Version | Indicates an HTTP version. OBS uses HTTP 1.1. |
Status-Code | Indicates a status code. This element describes the state of a response. |
Reason-Phrase | Indicates a reason phrase. This element describes a status code in a short text. |
A status code consists of three digits. The first digit defines the type of a status code. Status codes are classified into five types based on request states, as described in Table 2.
Status Code | Description |
---|---|
1xx | Indicates that a request sent by a client has been received and is being processed by the server. This status code is returned to inform the client must wait before the request is successfully processed. |
2xx | Indicates that a request has been received, understood, and accepted. |
3xx | Indicates that a request can be successfully processed only after being redirected. |
4xx | Indicates that a request fails to be processed due to client error. For example, a request sent by a client is invalid or uses incorrect syntax. |
5xx | Indicates that a request fails to be processed due to client error. |
1xx status codes indicate a provisional response. Table 3 describes all 1xx status codes.
Status Code | Description | Returned After |
---|---|---|
100 Continue | Indicates that the initial part of the request has been received and has not yet been rejected by the server and the client should continue with its request. |
|
2xx status codes indicate that a request has been successfully processed by the server. Table 4 describes all 2xx status codes.
Status Code | Description | Returned After |
---|---|---|
200 OK | Indicates that the server has accepted a request. |
|
201 Created | Indicates that a request response contains an XML file recording response details. |
|
202 Accepted | Indicates that a command for restoring a cold object is successfully delivered. | The cold objects are not restored before the storage objects restore. After the cold objects are restored, 202 is returned. |
204 No Content | Indicates that the server has processed a request successfully and no content is returned. |
|
206 Partial Content | Succeeded in downloading some of the objects. | The message is returned after the objects with the Range header are successfully downloaded. |
3xx status codes indicate that a request can be successfully processed only after being redirected. Table 5 describes all 3xx status codes.
Status Code | Description | Returned After |
---|---|---|
303 See Other | Indicates that a client can use another URI to obtain a specific object. |
|
304 Not Modified | Indicates that the requested resource in a GET request is not modified at the specified time. |
|
307 Moved Temporarily | Indicates that a request has been redirected. |
|
4xx status codes indicate that a request fails to be processed due to a client error. When 4xx status codes are returned (except response to a HEAD request), the server must contain an error message with an error explanation. 4xx status codes apply to all request methods. Table 6 describes all 4xx status codes.
Status Code | Description | Returned After |
---|---|---|
400 Bad Request | Indicates that the syntax of a request is incorrect. | A request in incorrect syntax or containing incorrect parameters is sent. |
403 Forbidden | Indicates that a request fails to be authenticated. | The requested user does not exist or authentication information in a sent request is incorrect. |
404 Not Found | Indicates that the requested resource does not exist. | The requested resource (such as a bucket or an object) does not exist. |
411 Length Required | Indicates that the Content-Length header is missing in a request. | A request containing no Content-Length header is sent. |
5xx status codes indicate that a request fails to be processed due to a client error. A 5xx status code is returned together with a response body containing error details. 5xx status codes can be returned after requests using all HTTP methods (except HEAD) are sent. Table 7 describes all 5xx status codes.
Status Code | Description | Returned After |
---|---|---|
500 Internal Error | Indicates that an error occurs on the server. | An error occurs on the server. |
503 Service Unavailable | Indicates that the server is overloaded. | The server realizes that it is processing too many requests at once. |
Response Headers¶
Response headers are included in responses to provide additional information about servers and requested resources. Table 8 lists the response headers.
Header | Description | Applicable To |
---|---|---|
Content-Length | Indicates the length of a response body. | All responses |
Date | Indicates the date when a request response is returned. | All responses |
x-amz-request-id | Indicates the unique identifier for an OBS request. | All responses |
x-amz-id-2 | Indicates a special token that helps OBS troubleshoot faults. | All responses |
x-reserved | Indicates the copyright. | All responses |
ETag | Indicates the hash value of an object. The entity tag (ETag) only reflects changes to the contents of an object, not its metadata. | Responses returned after PUT Object, GET Object, and HEAD Object requests are successfully processed. |
Last-Modified | Indicates the date and time at which the last modification to an object is recorded. | Responses returned after GET Object and HEAD Object requests are successfully processed. |
Location | Indicates the URI of an object. | Responses returned after a POST Object request is successfully processed. |
Response Body¶
A response body is included in a request response under the following conditions:
Obtaining object content
If a requested object is not blank, the response body is the content of the object.
Obtaining the ACL of a bucket or object
The response body is the ACL of the requested bucket or object in the XML format.
Client error
The response body describes the client error in detail in the XML format so that the user can perform further operations. For details, see Table 1.
Server error
The response body contains error details in the XML format.
Error Response¶
An error response is returned if a request is incorrect, permission is incorrect, or the requested bucket or object is not found. An error response contains error details in the XML format. The following is an example error response returned after the requested object is not found:
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<RequestId>FDBD2D47937FBD89F71285474962843</RequestId>
<HostId>RkRCRDJENDc5MzdGQkQ4OUY3MTI4NTQ3NDk2Mjg0M0FB
QUFBQUFBYmJiYmJiYmJD</HostId>
……
</Error>
Table 9 describes the common elements contained in an error response.
Element | Description |
---|---|
Code | A character string that uniquely identifies an error. |
Error | Container for all error elements in the XML response body. |
Message | Error details that help you read and understand an error. |
RequestId | The unique ID of the request whose error response is returned. |
HostId | ID of the server that returns an error response. |
The preceding elements are commonly found in error responses in the XML format. To facilitate error diagnosis, most error responses also contain other elements to describe error details. For example, if the MD5 value calculated by OBS is inconsistent with that specified in a request for uploading an object, OBS returns an error response that contains both the calculated MD5 value and the user-defined MD5 value.