Common REST API Elements
Amazon S3 REST Operations are HTTP requests, as defined by RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt). This section describes how Amazon S3 uses HTTP and the parts of HTTP requests and responses that Amazon S3 REST operations have in common. Detailed descriptions of individual operations are provided later in this guide.
All REST requests use a common set of endpoints. For information, see Request Endpoints.
A typical REST operation consists of a sending a single HTTP request to Amazon S3, followed by waiting for an HTTP response. Like any HTTP request, a request to Amazon S3 contains a request method, a URI, request headers, and sometimes a query string and request body. The response contains a status code, response headers, and sometimes a response body.
Following is an example that shows how to get an object named "Nelson" from the "quotes" bucket.
Sample Request
GET /Nelson HTTP/1.1 Host: quotes.s3.amazonaws.com Date: Wed, 01 Mar 2006 12:00:00 GMT Authorization: AWS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE=
Sample Response
HTTP/1.1 200 OK x-amz-id-2: qBmKRcEWBBhH6XAqsKU/eg24V3jf/kWKN9dJip1L/FpbYr9FDy7wWFurfdQOEMcY x-amz-request-id: F2A8CCCA26B4B26D Date: Wed, 01 Mar 2006 12:00:00 GMT Last-Modified: Sun, 1 Jan 2006 12:00:00 GMT ETag: "828ef3fdfa96f00ad9f27c383fc9ac7f" Content-Type: text/plain Content-Length: 5 Connection: close Server: AmazonS3 ha-ha
Common Request Headers
Amazon S3 REST requests include headers which contain basic information about the request. Following is a table that describes common headers for Amazon S3 REST requests.
Header Name | Description | Required | |||
---|---|---|---|---|---|
Content-Length
|
Length of the message (without the headers) according to RFC 2616. Condition: Required for PUTs and operations that load XML, such as logging and ACLs. |
Conditional | |||
Content-Type
|
The content type of the resource. Example: text/plain
|
No | |||
Date
|
The current date and time according to the requester. Example:
Wed, 01 Mar 2006 12:00:00 GMT
|
Yes | |||
Host
|
Normally, the value of Host is Condition: Required for HTTP 1.1 (most toolkits add this header automatically); optional for HTTP/1.0 requests. |
Conditional | |||
Authorization
|
The information required for request authentication. For more information, see The Authentication Header for details about the format. | Yes | |||
x-amz-security-token
|
The security tokens for operations that use Amazon DevPay. Each request
that uses Amazon DevPay requires two Condition: Required for requests that use Amazon DevPay.
|
Conditional |