doc-exports/docs/obs/s3api/en-us_topic_0125560464.html
Jawei, Li 1a4c1a720a OBS s3api 2.0.38.SP5
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Jawei, Li <lijiawei5@huawei.com>
Co-committed-by: Jawei, Li <lijiawei5@huawei.com>
2022-11-16 14:51:13 +00:00

191 lines
16 KiB
HTML

<a name="EN-US_TOPIC_0125560464"></a><a name="EN-US_TOPIC_0125560464"></a>
<h1 class="topictitle1">OPTIONS Bucket</h1>
<div id="body28237324"><p id="EN-US_TOPIC_0125560464__p22974714"><strong id="EN-US_TOPIC_0125560464__b52809326">OPTIONS</strong> refers to pre-requests that are sent to servers by clients. Generally, you can use these requests to check whether clients have permission to perform operations on servers. Only after a pre-request is returned successfully, clients start to execute the follow-up requests.</p>
<p id="EN-US_TOPIC_0125560464__p5445839">OBS allows buckets to store static web resources. The buckets of OBS can serve as website resources if the buckets are properly used. In this scenario, buckets in OBS serve as servers to process <strong id="EN-US_TOPIC_0125560464__b5521893">OPTIONS</strong> pre-requests from clients.</p>
<p id="EN-US_TOPIC_0125560464__p49012555">OBS can process <strong id="EN-US_TOPIC_0125560464__b49697041">OPTIONS</strong> pre-requests only after CORS is configured for buckets in OBS. For details about CORS, see section <a href="en-us_topic_0125560238.html">PUT Bucket CORS</a>.</p>
<div class="section" id="EN-US_TOPIC_0125560464__section6578292"><h4 class="sectiontitle">Request Syntax</h4><pre class="screen" id="EN-US_TOPIC_0125560464__screen32646184122651">OPTIONS / HTTP/1.1
User-Agent: agent
Host: bucketname.obs.example.com
Accept: */*
Date: date
Authorization: authorization
Origin: origin
Access-Control-Request-Method: method</pre>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section59204636"><h4 class="sectiontitle">Request Parameters</h4><p id="EN-US_TOPIC_0125560464__p9063573">This request involves no parameters.</p>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section63079676"><h4 class="sectiontitle">Request Headers</h4><p id="EN-US_TOPIC_0125560464__p63060783"><a href="#EN-US_TOPIC_0125560464__table57465365">Table 1</a> lists the request headers.</p>
<div class="tablenoborder"><a name="EN-US_TOPIC_0125560464__table57465365"></a><a name="table57465365"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0125560464__table57465365" frame="border" border="1" rules="all"><caption><b>Table 1 </b>OPTIONS request headers</caption><thead align="left"><tr id="EN-US_TOPIC_0125560464__row44805132"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.6.3.2.4.1.1"><p id="EN-US_TOPIC_0125560464__p5337050">Header</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.6.3.2.4.1.2"><p id="EN-US_TOPIC_0125560464__p29647872">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.6.3.2.4.1.3"><p id="EN-US_TOPIC_0125560464__p52667431">Remarks</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0125560464__row38203510"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560464__p7476630">Origin</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560464__p1627311">Indicates an origin specified by a pre-request. Generally, it is a domain name.</p>
<p id="EN-US_TOPIC_0125560464__p14645800">Type: String</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560464__p45459112">Mandatory</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row6478825"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560464__p55022811">Access-Control-Request-Method</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560464__p27662693">Indicates an HTTP method that can be used by a request. The request can use multiple method headers.</p>
<p id="EN-US_TOPIC_0125560464__p47637651">Type: String</p>
<p id="EN-US_TOPIC_0125560464__p26085680">Valid values: <strong id="EN-US_TOPIC_0125560464__b33444533">GET</strong>, <strong id="EN-US_TOPIC_0125560464__b32565348">PUT</strong>, <strong id="EN-US_TOPIC_0125560464__b24652676">HEAD</strong>, <strong id="EN-US_TOPIC_0125560464__b20547495">POST</strong>, and <strong id="EN-US_TOPIC_0125560464__b50709735">DELETE</strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560464__p13847879">Mandatory</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row57522049"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560464__p28774374">Access-Control-Request-Headers</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560464__p49022972">Indicates the HTTP headers of a request. The request can use multiple HTTP headers.</p>
<p id="EN-US_TOPIC_0125560464__p38553569">Type: String</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560464__p35831362">Optional</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row13892162514268"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560464__p13931152772615">x-amz-security-token</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560464__p9931142712260">Header field used to identify the request of a federated user. When the federal authentication function is enabled, users sending such requests are identified as federated users.</p>
<p id="EN-US_TOPIC_0125560464__p19316279264">Type: string</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.6.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560464__p59311327112611">Optional. This parameter must be carried in the request sent by federated users.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section30846174"><h4 class="sectiontitle">Request Elements</h4><p id="EN-US_TOPIC_0125560464__p15715441">This request involves no elements.</p>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section39517886"><h4 class="sectiontitle">Response Syntax</h4><pre class="screen" id="EN-US_TOPIC_0125560464__screen809060312266">HTTP/1.1 status_code
x-amz-request-id: request id
x-amz-id-2: id
Access-Control-Allow-Origin: origin
Access-Control-Allow-Methods: method
Access-Control-Allow-Header: header
Access-Control-Max-Age: seconds
Access-Control-Expose-Headers: header
Date: date
Content-Length: length</pre>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section20116657"><h4 class="sectiontitle">Response Headers</h4><p id="EN-US_TOPIC_0125560464__p44796928"><a href="#EN-US_TOPIC_0125560464__table7221243">Table 2</a> lists the response headers.</p>
<div class="tablenoborder"><a name="EN-US_TOPIC_0125560464__table7221243"></a><a name="table7221243"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0125560464__table7221243" frame="border" border="1" rules="all"><caption><b>Table 2 </b>CORS response headers</caption><thead align="left"><tr id="EN-US_TOPIC_0125560464__row23871500"><th align="left" class="cellrowborder" valign="top" width="35.3%" id="mcps1.3.9.3.2.3.1.1"><p id="EN-US_TOPIC_0125560464__p54543318">Header</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="64.7%" id="mcps1.3.9.3.2.3.1.2"><p id="EN-US_TOPIC_0125560464__p55932620">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0125560464__row34248408"><td class="cellrowborder" valign="top" width="35.3%" headers="mcps1.3.9.3.2.3.1.1 "><p id="EN-US_TOPIC_0125560464__p22657631">Access-Control-Allow-Origin</p>
</td>
<td class="cellrowborder" valign="top" width="64.7%" headers="mcps1.3.9.3.2.3.1.2 "><p id="EN-US_TOPIC_0125560464__p23328843">If the origin of a request meets server CORS configuration requirements, the response contains the origin.</p>
<p id="EN-US_TOPIC_0125560464__p8633003">Type: String</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row10588164"><td class="cellrowborder" valign="top" width="35.3%" headers="mcps1.3.9.3.2.3.1.1 "><p id="EN-US_TOPIC_0125560464__p52334961">Access-Control-Allow-Headers</p>
</td>
<td class="cellrowborder" valign="top" width="64.7%" headers="mcps1.3.9.3.2.3.1.2 "><p id="EN-US_TOPIC_0125560464__p11273467">If the headers of a request meet server CORS configuration requirements, the response contains the headers.</p>
<p id="EN-US_TOPIC_0125560464__p34352342">Type: String</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row40735625"><td class="cellrowborder" valign="top" width="35.3%" headers="mcps1.3.9.3.2.3.1.1 "><p id="EN-US_TOPIC_0125560464__p11251332">Access-Control-Max-Age</p>
</td>
<td class="cellrowborder" valign="top" width="64.7%" headers="mcps1.3.9.3.2.3.1.2 "><p id="EN-US_TOPIC_0125560464__p38942675">Indicates <strong id="EN-US_TOPIC_0125560464__b132633127712">MaxAgeSeconds</strong> in the CORS configuration of a server.</p>
<p id="EN-US_TOPIC_0125560464__p240095">Type: Integer</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row2160855"><td class="cellrowborder" valign="top" width="35.3%" headers="mcps1.3.9.3.2.3.1.1 "><p id="EN-US_TOPIC_0125560464__p40811528">Access-Control-Allow-Methods</p>
</td>
<td class="cellrowborder" valign="top" width="64.7%" headers="mcps1.3.9.3.2.3.1.2 "><p id="EN-US_TOPIC_0125560464__p17399466">If the <strong id="EN-US_TOPIC_0125560464__b22377468">Access-Control-Request-Method</strong> of a request meets server CORS configuration requirements, the response contains the methods in the rule.</p>
<p id="EN-US_TOPIC_0125560464__p70628">Type: String</p>
<p id="EN-US_TOPIC_0125560464__p635658">Valid values: <strong id="EN-US_TOPIC_0125560464__b5720927">GET</strong>, <strong id="EN-US_TOPIC_0125560464__b51488348">PUT</strong>, <strong id="EN-US_TOPIC_0125560464__b60741955">HEAD</strong>, <strong id="EN-US_TOPIC_0125560464__b9806683">POST</strong>, and <strong id="EN-US_TOPIC_0125560464__b21151286">DELETE</strong></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row56143854"><td class="cellrowborder" valign="top" width="35.3%" headers="mcps1.3.9.3.2.3.1.1 "><p id="EN-US_TOPIC_0125560464__p51358334">Access-Control-Expose-Headers</p>
</td>
<td class="cellrowborder" valign="top" width="64.7%" headers="mcps1.3.9.3.2.3.1.2 "><p id="EN-US_TOPIC_0125560464__p66384370">Indicates <strong id="EN-US_TOPIC_0125560464__b60588421">ExposeHeader</strong> in the CORS configuration of a server.</p>
<p id="EN-US_TOPIC_0125560464__p8424883">Type: String</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section46832193"><h4 class="sectiontitle">Response Elements</h4><p id="EN-US_TOPIC_0125560464__p34833129">This response involves no elements.</p>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section18836558"><h4 class="sectiontitle">Error Responses</h4><p id="EN-US_TOPIC_0125560464__p2911240">For details about other errors, see <a href="en-us_topic_0125560440.html#EN-US_TOPIC_0125560440__table30733758">Table 1</a>. In addition, this response also may contain special errors, as described in <a href="#EN-US_TOPIC_0125560464__table64991193">Table 3</a>.</p>
<div class="tablenoborder"><a name="EN-US_TOPIC_0125560464__table64991193"></a><a name="table64991193"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0125560464__table64991193" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Special errors</caption><thead align="left"><tr id="EN-US_TOPIC_0125560464__row53469045"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.11.3.2.4.1.1"><p id="EN-US_TOPIC_0125560464__p36025402">Error Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.11.3.2.4.1.2"><p id="EN-US_TOPIC_0125560464__p32376435">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.11.3.2.4.1.3"><p id="EN-US_TOPIC_0125560464__p5245577">HTTP Status Code</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0125560464__row22238563"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560464__p56493161">Bad Request</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560464__p12543365">Invalid Access-Control-Request-Method: null</p>
<p id="EN-US_TOPIC_0125560464__p45781421">When CORS and OPTIONS are configured for a bucket, no method header is added.</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560464__p17307650">400 Bad Request</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row21551128"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560464__p810977">Bad Request</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560464__p65689182">Insufficient information. Origin request header needed.</p>
<p id="EN-US_TOPIC_0125560464__p54331732">When CORS and OPTIONS are configured for a bucket, no origin header is added.</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560464__p38794171">400 Bad Request</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0125560464__row13603222"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.1 "><p id="EN-US_TOPIC_0125560464__p28119201">AccessForbidden</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.2 "><p id="EN-US_TOPIC_0125560464__p63062784">CORSResponse: This CORS request is not allowed. This is usually because the evaluation of Origin, request method / Access-Control-Request-Method or Access-Control-Request-Headers are not whitelisted by the resource's CORS spec.</p>
<p id="EN-US_TOPIC_0125560464__p30694147">When CORS and OPTIONS are configured for a bucket, origin, method, and headers do not match any rule.</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.11.3.2.4.1.3 "><p id="EN-US_TOPIC_0125560464__p3197948">403 Forbidden</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section49531474"><h4 class="sectiontitle">Sample Request</h4><pre class="screen" id="EN-US_TOPIC_0125560464__screen6086305012259">OPTIONS / HTTP/1.1
User-Agent: curl/7.19.0 (x86_64-suse-linux-gnu) libcurl/7.19.0 OpenSSL/0.9.8{ zlib/1.2.3 libidn/1.10
Host: bucketname.obs.example.com
Accept: */*
Date: Tue, 28 Apr 2015 12:43:15 +0000
Authorization: AWS D13E0C94E722DD69423C:02VOjl2Z5B7mUd+G6zr0Dql5CW8=
Origin:www.example.com
Access-Control-Request-Method:HEAD
Access-Control-Request-Headers:acc_header_1
Access-Control-Request-Headers:acc_header_2</pre>
</div>
<div class="section" id="EN-US_TOPIC_0125560464__section1462434713910"><h4 class="sectiontitle">Sample Response</h4><pre class="screen" id="EN-US_TOPIC_0125560464__screen47681201122517">HTTP/1.1 200 OK
x-amz-request-id: 0350FC4D73DDA0D3A6FC2CBE01A7943A
x-amz-id-2: ANHl/5gbYTwbfQat5+QZpWdnuE5DV83RXCyGZgBrbDVzVtdtGkqb9ZOepAX3Yr/z
x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc
Access-Control-Allow-Origin: www.example.com
Access-Control-Allow-Methods: POST,GET,HEAD,PUT
Access-Control-Allow-Headers: acc_header_1,acc_header_2
Access-Control-Max-Age: 100
Access-Control-Expose-Headers: exp_header_1
Date: Tue, 28 Apr 2015 12:45:34 GMT
Content-Length: 0</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0125560493.html">Operations on Buckets</a></div>
</div>
</div>