doc-exports/docs/obs/api-ref/obs_04_0077.html
zhangyue 7d2a7ec198 OBS API DOC
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: zhangyue <zhangyue164@huawei.com>
Co-committed-by: zhangyue <zhangyue164@huawei.com>
2024-11-05 16:37:11 +00:00

222 lines
17 KiB
HTML

<a name="obs_04_0077"></a><a name="obs_04_0077"></a>
<h1 class="topictitle1">OPTIONS Bucket</h1>
<div id="body61864177"><div class="section" id="obs_04_0077__section5584184924715"><h4 class="sectiontitle">Functions</h4><p class="msonormal" id="obs_04_0077__p31722811">OPTIONS refers to pre-requests that are sent to servers by clients. Generally, the requests are used to check whether clients have permissions to perform operations on servers. Only after a pre-request is returned successfully, clients start to execute the follow-up requests.</p>
<p class="msonormal" id="obs_04_0077__p17069843">OBS allows static web resources to be stored in buckets with appropriate configurations. In this scenario, buckets in the OBS serve as servers to process OPTIONS pre-requests from clients.</p>
<p class="msonormal" id="obs_04_0077__p648973918569">OBS can process OPTIONS pre-requests only after CORS is configured for buckets in OBS. For details about CORS, see <a href="obs_04_0074.html">Configuring Bucket CORS</a>.</p>
</div>
<div class="section" id="obs_04_0077__section9125142514612"><h4 class="sectiontitle">Differences Between OPTIONS Bucket and OPTIONS Object</h4><p id="obs_04_0077__p92971585546">With the OPTIONS Object, you need to specify an object name in the URL, but an object name is not required with the OPTIONS Bucket, which uses the bucket domain name as the URL. The request lines of the two methods are as follows:</p>
<pre class="screen" id="obs_04_0077__screen53331759111919">OPTIONS /object HTTP/1.1</pre>
<pre class="screen" id="obs_04_0077__screen666703202019">OPTIONS / HTTP/1.1</pre>
</div>
<div class="section" id="obs_04_0077__section40480049"><h4 class="sectiontitle">Request Syntax</h4><div class="codecoloring" codetype="Xml" id="obs_04_0077__screen1828802"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span></pre></div></td><td class="code"><div><pre><span></span>OPTIONS<span class="w"> </span>/<span class="w"> </span>HTTP/1.1<span class="w"> </span>
Host:<span class="w"> </span>bucketname.obs.region.example.com
Date:<span class="w"> </span>date
Authorization:<span class="w"> </span>authorization
Origin:<span class="w"> </span>origin
Access-Control-Request-Method:<span class="w"> </span>method
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="obs_04_0077__section28776129"><h4 class="sectiontitle">Request Parameters</h4><p class="msonormal" id="obs_04_0077__p31205796">This request contains no message parameters.</p>
</div>
<div class="section" id="obs_04_0077__section57658576"><h4 class="sectiontitle">Request Headers</h4><p class="msonormal" id="obs_04_0077__p44641568">This request uses the headers described in <a href="#obs_04_0077__table2585568620633">Table 1</a>.</p>
<div class="tablenoborder"><a name="obs_04_0077__table2585568620633"></a><a name="table2585568620633"></a><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0077__table2585568620633" frame="border" border="1" rules="all"><caption><b>Table 1 </b>OPTIONS request headers</caption><thead align="left"><tr id="obs_04_0077__row61203858"><th align="left" class="cellrowborder" valign="top" width="19.387755102040817%" id="mcps1.3.5.3.2.4.1.1"><p id="obs_04_0077__p58565490">Header</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="63.26530612244898%" id="mcps1.3.5.3.2.4.1.2"><p id="obs_04_0077__p46184267">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="17.346938775510203%" id="mcps1.3.5.3.2.4.1.3"><p id="obs_04_0077__p49938116">Mandatory</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_04_0077__row18455557"><td class="cellrowborder" valign="top" width="19.387755102040817%" headers="mcps1.3.5.3.2.4.1.1 "><p id="obs_04_0077__p18505143">Origin</p>
</td>
<td class="cellrowborder" valign="top" width="63.26530612244898%" headers="mcps1.3.5.3.2.4.1.2 "><p id="obs_04_0077__p22521601">Origin of the cross-domain request specified by the pre-request. Generally, it is a domain name set in CORS.</p>
<p id="obs_04_0077__p1367823">Type: string</p>
</td>
<td class="cellrowborder" valign="top" width="17.346938775510203%" headers="mcps1.3.5.3.2.4.1.3 "><p id="obs_04_0077__p43684849">Yes</p>
</td>
</tr>
<tr id="obs_04_0077__row57619328"><td class="cellrowborder" valign="top" width="19.387755102040817%" headers="mcps1.3.5.3.2.4.1.1 "><p id="obs_04_0077__p36653955">Access-Control-Request-Method</p>
</td>
<td class="cellrowborder" valign="top" width="63.26530612244898%" headers="mcps1.3.5.3.2.4.1.2 "><p id="obs_04_0077__p16180416">An HTTP method that can be used by a request. The request can use multiple method headers.</p>
<p id="obs_04_0077__p11406019">Type: string</p>
<p id="obs_04_0077__p35545309">Value options: <strong id="obs_04_0077__b6532175719460">GET</strong>, <strong id="obs_04_0077__b1753255794620">PUT</strong>, <strong id="obs_04_0077__b1053335754613">HEAD</strong>, <strong id="obs_04_0077__b155331157194620">POST</strong>, <strong id="obs_04_0077__b4533105714612">DELETE</strong></p>
</td>
<td class="cellrowborder" valign="top" width="17.346938775510203%" headers="mcps1.3.5.3.2.4.1.3 "><p id="obs_04_0077__p60597762">Yes</p>
</td>
</tr>
<tr id="obs_04_0077__row8508952"><td class="cellrowborder" valign="top" width="19.387755102040817%" headers="mcps1.3.5.3.2.4.1.1 "><p id="obs_04_0077__p18136477">Access-Control-Request-Headers</p>
</td>
<td class="cellrowborder" valign="top" width="63.26530612244898%" headers="mcps1.3.5.3.2.4.1.2 "><p id="obs_04_0077__p59768510">HTTP headers of a request. The request can use multiple HTTP headers.</p>
<p id="obs_04_0077__p1045685">Type: string</p>
</td>
<td class="cellrowborder" valign="top" width="17.346938775510203%" headers="mcps1.3.5.3.2.4.1.3 "><p id="obs_04_0077__p17591693">No</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="obs_04_0077__section49165144"><h4 class="sectiontitle">Request Elements</h4><p class="msonormal" id="obs_04_0077__p15641013">This request involves no elements.</p>
</div>
<div class="section" id="obs_04_0077__section39833112"><h4 class="sectiontitle">Response Syntax</h4><div class="codecoloring" codetype="Xml" id="obs_04_0077__screen58962517"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span>
<span class="normal">9</span></pre></div></td><td class="code"><div><pre><span></span>HTTP/1.1<span class="w"> </span>status_code
Content-Type:<span class="w"> </span>application/xml<span class="w"> </span>
Access-Control-Allow-Origin:<span class="w"> </span>origin
Access-Control-Allow-Methods:<span class="w"> </span>method
Access-Control-Allow-Header:<span class="w"> </span>header
Access-Control-Max-Age:<span class="w"> </span>time
Access-Control-Expose-Headers:<span class="w"> </span>header
Date:<span class="w"> </span>date
Content-Length:<span class="w"> </span>length
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="obs_04_0077__section22953690"><h4 class="sectiontitle">Response Headers</h4><p class="msonormal" id="obs_04_0077__p65663855">The response uses the following headers as described in <a href="#obs_04_0077__table40550587202855">Table 2</a>.</p>
<div class="tablenoborder"><a name="obs_04_0077__table40550587202855"></a><a name="table40550587202855"></a><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0077__table40550587202855" frame="border" border="1" rules="all"><caption><b>Table 2 </b>CORS response headers</caption><thead align="left"><tr id="obs_04_0077__row4273512"><th align="left" class="cellrowborder" valign="top" width="28.28282828282828%" id="mcps1.3.8.3.2.3.1.1"><p id="obs_04_0077__p10610183">Header</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="71.71717171717171%" id="mcps1.3.8.3.2.3.1.2"><p id="obs_04_0077__p54118519">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_04_0077__row21523936"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0077__p65717225">Access-Control-Allow-Origin</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0077__p21494970">If the origin of a request meets server CORS configuration requirements, the response contains the origin.</p>
<p id="obs_04_0077__p59237005">Type: string</p>
</td>
</tr>
<tr id="obs_04_0077__row63371004"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0077__p32777686">Access-Control-Allow-Headers</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0077__p37746929">If the headers of a request meet server CORS configuration requirements, the response contains the headers.</p>
<p id="obs_04_0077__p4178046">Type: string</p>
</td>
</tr>
<tr id="obs_04_0077__row37602421"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0077__p25897224">Access-Control-Max-Age</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0077__p17300437">Value of MaxAgeSeconds in the CORS configuration of a server</p>
<p id="obs_04_0077__p21486208">Type: integer</p>
</td>
</tr>
<tr id="obs_04_0077__row59158146"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0077__p27080503">Access-Control-Allow-Methods</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0077__p46037149">If the Access-Control-Request-Method of a request meets server CORS configuration requirements, the response contains the methods in the rule.</p>
<p id="obs_04_0077__p11681162">Type: string</p>
<p id="obs_04_0077__p38021595">Value options: <strong id="obs_04_0077__b33331911474">GET</strong>, <strong id="obs_04_0077__b173344134717">PUT</strong>, <strong id="obs_04_0077__b83344112477">HEAD</strong>, <strong id="obs_04_0077__b1033419114476">POST</strong>, <strong id="obs_04_0077__b133348114719">DELETE</strong></p>
</td>
</tr>
<tr id="obs_04_0077__row6650043"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0077__p1782642">Access-Control-Expose-Headers</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0077__p10176276">Value of ExposeHeader in the CORS configuration of a server</p>
<p id="obs_04_0077__p24477626">Type: string</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="obs_04_0077__section5256624"><h4 class="sectiontitle">Response Elements</h4><p class="msonormal" id="obs_04_0077__p36530666">This response contains no elements.</p>
</div>
<div class="section" id="obs_04_0077__section47309617"><h4 class="sectiontitle">Error Responses</h4><p class="msonormal" id="obs_04_0077__p6193979"><a href="#obs_04_0077__table1322139420210">Table 3</a> describes possible special errors in the request.</p>
<div class="tablenoborder"><a name="obs_04_0077__table1322139420210"></a><a name="table1322139420210"></a><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0077__table1322139420210" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Special error</caption><thead align="left"><tr id="obs_04_0077__row42502533"><th align="left" class="cellrowborder" valign="top" width="26.53061224489796%" id="mcps1.3.10.3.2.4.1.1"><p id="obs_04_0077__p20153131">Error Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="48.97959183673469%" id="mcps1.3.10.3.2.4.1.2"><p id="obs_04_0077__p21790951">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24.489795918367346%" id="mcps1.3.10.3.2.4.1.3"><p id="obs_04_0077__p20236574">HTTP Status Code</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_04_0077__row28549818"><td class="cellrowborder" valign="top" width="26.53061224489796%" headers="mcps1.3.10.3.2.4.1.1 "><p id="obs_04_0077__p30833955">Bad Request</p>
</td>
<td class="cellrowborder" valign="top" width="48.97959183673469%" headers="mcps1.3.10.3.2.4.1.2 "><p id="obs_04_0077__p14522432">Invalid Access-Control-Request-Method: null</p>
<p id="obs_04_0077__p63593030">When CORS and OPTIONS are configured for a bucket, no method header is added.</p>
</td>
<td class="cellrowborder" valign="top" width="24.489795918367346%" headers="mcps1.3.10.3.2.4.1.3 "><p id="obs_04_0077__p50761805">400 BadRequest</p>
</td>
</tr>
<tr id="obs_04_0077__row54203064"><td class="cellrowborder" valign="top" width="26.53061224489796%" headers="mcps1.3.10.3.2.4.1.1 "><p id="obs_04_0077__p28372067">Bad Request</p>
</td>
<td class="cellrowborder" valign="top" width="48.97959183673469%" headers="mcps1.3.10.3.2.4.1.2 "><p id="obs_04_0077__p16436066">Insufficient information. Origin request header needed.</p>
<p id="obs_04_0077__p13706869">When CORS and OPTIONS are configured for a bucket, no origin header is added.</p>
</td>
<td class="cellrowborder" valign="top" width="24.489795918367346%" headers="mcps1.3.10.3.2.4.1.3 "><p id="obs_04_0077__p36514574">400 BadRequest</p>
</td>
</tr>
<tr id="obs_04_0077__row60195710"><td class="cellrowborder" valign="top" width="26.53061224489796%" headers="mcps1.3.10.3.2.4.1.1 "><p id="obs_04_0077__p44014314">AccessForbidden</p>
</td>
<td class="cellrowborder" valign="top" width="48.97959183673469%" headers="mcps1.3.10.3.2.4.1.2 "><p id="obs_04_0077__p8389707">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 specification.</p>
<p id="obs_04_0077__p8398507">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="24.489795918367346%" headers="mcps1.3.10.3.2.4.1.3 "><p id="obs_04_0077__p9190486">403 Forbidden</p>
</td>
</tr>
</tbody>
</table>
</div>
<p class="msonormal" id="obs_04_0077__p15605515">For other errors, see <a href="obs_04_0115.html#obs_04_0115__d0e843">Table 2</a>.</p>
</div>
<div class="section" id="obs_04_0077__section14482163815396"><h4 class="sectiontitle">Sample Request</h4><div class="codecoloring" codetype="Xml" id="obs_04_0077__screen8484163863919"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td><td class="code"><div><pre><span></span>OPTIONS<span class="w"> </span>/<span class="w"> </span>HTTP/1.1
User-Agent:<span class="w"> </span>curl/7.29.0
Host:<span class="w"> </span>examplebucket.obs.region.example.com
Accept:<span class="w"> </span>*/*
Date:<span class="w"> </span>WED,<span class="w"> </span>01<span class="w"> </span>Jul<span class="w"> </span>2015<span class="w"> </span>04:02:15<span class="w"> </span>GMT
Authorization:<span class="w"> </span>OBS<span class="w"> </span>H4IPJX0TQTHTHEBQQCEC:7RqP1vjemo6U+Adv9/Y6eGzWrzA=
Origin:<span class="w"> </span>www.example.com
Access-Control-Request-Method:<span class="w"> </span>PUT
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="obs_04_0077__section76081155815"><h4 class="sectiontitle">Sample Response</h4><div class="codecoloring" codetype="Xml" id="obs_04_0077__screen8485113814"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span></pre></div></td><td class="code"><div><pre><span></span>HTTP/1.1<span class="w"> </span>200<span class="w"> </span>OK
Server:<span class="w"> </span>OBS
x-obs-request-id:<span class="w"> </span>BF260000016436314E8FF936946DBC9C
Access-Control-Allow-Origin:<span class="w"> </span>www.example.com
Access-Control-Allow-Methods:<span class="w"> </span>POST,GET,HEAD,PUT,DELETE
Access-Control-Max-Age:<span class="w"> </span>100
Access-Control-Expose-Headers:<span class="w"> </span>ExposeHeader_1,ExposeHeader_2
Access-Control-Allow-Credentials:<span class="w"> </span>true
x-obs-id-2:<span class="w"> </span>32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTlYimJvOyJncCLNm5y/iz6MAGLNxTuS
Date:<span class="w"> </span>WED,<span class="w"> </span>01<span class="w"> </span>Jul<span class="w"> </span>2015<span class="w"> </span>04:02:15<span class="w"> </span>GMT
Content-Length:<span class="w"> </span>0
</pre></div></td></tr></table></div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_04_0070.html">Static Website Hosting</a></div>
</div>
</div>