doc-exports/docs/obs/api-ref/obs_04_0075.html
Jawei, Li f1cb839979 OBS api-ref 2.0.38.SP5
Reviewed-by: gtema <artem.goncharov@gmail.com>
Co-authored-by: Jawei, Li <lijiawei5@huawei.com>
Co-committed-by: Jawei, Li <lijiawei5@huawei.com>
2022-11-03 11:54:51 +00:00

218 lines
14 KiB
HTML

<a name="obs_04_0075"></a><a name="obs_04_0075"></a>
<h1 class="topictitle1">Obtaining the CORS Configuration of a Bucket</h1>
<div id="body56795861"><div class="section" id="obs_04_0075__section5584184924715"><h4 class="sectiontitle">Functions</h4><p class="msonormal" id="obs_04_0075__p23627439">You can perform this operation to obtain CORS configuration information about a specified bucket.</p>
<p class="msonormal" id="obs_04_0075__p11320361">To perform this operation, you must have the <strong id="obs_04_0075__b61721457267">GetBucketCORS</strong> permission. By default, only the bucket owner can perform this operation. The bucket owner can grant the permission to other users by configuring the bucket policy or user policy.</p>
</div>
<div class="section" id="obs_04_0075__section34774393"><h4 class="sectiontitle">Request Syntax</h4><div class="codecoloring" codetype="Xml" id="obs_04_0075__screen37062010"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4</pre></div></td><td class="code"><div class="highlight"><pre><span></span>GET /?cors HTTP/1.1
Host: bucketname.obs.region.example.com
Date: date
Authorization: authorization
</pre></div>
</td></tr></table></div>
</div>
<div class="section" id="obs_04_0075__section44534087"><h4 class="sectiontitle">Request Parameters</h4><p class="msonormal" id="obs_04_0075__p17494789">This request contains no parameter.</p>
</div>
<div class="section" id="obs_04_0075__section65262468"><h4 class="sectiontitle">Request Headers</h4><p class="msonormal" id="obs_04_0075__p7791789">This request uses common headers. For details, see <a href="obs_04_0007.html#obs_04_0007__table25197309">Table 3</a>.</p>
</div>
<div class="section" id="obs_04_0075__section50491305"><h4 class="sectiontitle">Request Elements</h4><p class="msonormal" id="obs_04_0075__p43069754">This request involves no elements.</p>
</div>
<div class="section" id="obs_04_0075__section51768568"><h4 class="sectiontitle">Response Syntax</h4><div class="codecoloring" codetype="Xml" id="obs_04_0075__screen66098050"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11</pre></div></td><td class="code"><div class="highlight"><pre><span></span>HTTP/1.1 status_code
Content-Type: application/xml
Date: date
Content-Length: length
<span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;</span>
<span class="nt">&lt;CORSConfiguration</span> <span class="na">xmlns=</span><span class="s">&quot;http://obs.region.example.com/doc/2015-06-30/&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;CORSRule&gt;</span>
...
<span class="nt">&lt;/CORSRule&gt;</span>
<span class="nt">&lt;/CORSConfiguration&gt;</span>
</pre></div>
</td></tr></table></div>
</div>
<div class="section" id="obs_04_0075__section63263928"><h4 class="sectiontitle">Response Headers</h4><p class="msonormal" id="obs_04_0075__p1512332591013">The response to the request uses common headers. For details, see <a href="obs_04_0013.html#obs_04_0013__d0e686">Table 1</a>.</p>
</div>
<div class="section" id="obs_04_0075__section32504443"><h4 class="sectiontitle">Response Elements</h4><p class="msonormal" id="obs_04_0075__p50228350">This response contains elements to detail the configuration. <a href="#obs_04_0075__table2259502317110">Table 1</a> describes the elements.</p>
<div class="tablenoborder"><a name="obs_04_0075__table2259502317110"></a><a name="table2259502317110"></a><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0075__table2259502317110" frame="border" border="1" rules="all"><caption><b>Table 1 </b>CORS configuration elements</caption><thead align="left"><tr id="obs_04_0075__row663422"><th align="left" class="cellrowborder" valign="top" width="28.28282828282828%" id="mcps1.3.8.3.2.3.1.1"><p id="obs_04_0075__p53737197">Element</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_0075__p57745689">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_04_0075__row46889193"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p39928261">CORSConfiguration</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p12963734">Root node of <strong id="obs_04_0075__b195838300469">CORSRules</strong> and its capacity cannot exceed 64 KB.</p>
<p id="obs_04_0075__p49564750">Type: Container</p>
<p id="obs_04_0075__p43429572">Ancestor: none</p>
</td>
</tr>
<tr id="obs_04_0075__row55321833"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p51883501">CORSRule</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p41814016">CORS rule. CORSConfiguration can contain a maximum of 100 rules.</p>
<p id="obs_04_0075__p40781832">Type: Container</p>
<p id="obs_04_0075__p31492173">Ancestor: CORSConfiguration</p>
</td>
</tr>
<tr id="obs_04_0075__row14994104"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p6562892">ID</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p61832237">Unique identifier of a rule. The value can contain a maximum of 255 characters.</p>
<p id="obs_04_0075__p19619221">Type: string</p>
<p id="obs_04_0075__p42355266">Ancestor: CORSRule</p>
</td>
</tr>
<tr id="obs_04_0075__row45653075"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p6911634">AllowedMethod</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p22971514">Method allowed by a CORS rule.</p>
<p id="obs_04_0075__p5417036">Type: string</p>
<p id="obs_04_0075__p48753330">Possible values are GET, PUT, HEAD, POST, and DELETE. </p>
<p id="obs_04_0075__p36126787">Ancestor: CORSRule</p>
</td>
</tr>
<tr id="obs_04_0075__row56705634"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p29753651">AllowedOrigin</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p61235532">Indicates an origin that is allowed by a CORS rule. It is a character string and can contain a wildcard (*), and allows one wildcard character (*) at most.</p>
<p id="obs_04_0075__p14248884">Type: string</p>
<p id="obs_04_0075__p61131094">Ancestor: CORSRule</p>
</td>
</tr>
<tr id="obs_04_0075__row13308941"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p4282435">AllowedHeader</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p11332925">Indicates which headers are allowed in a PUT Bucket CORS request via the <strong id="obs_04_0075__b65266721105921">Access-Control-Request-Headers</strong> header. If a request contains <strong id="obs_04_0075__b1695414116425">Access-Control-Request- Headers</strong>, only a CORS request that matches the configuration of AllowedHeader is considered as a valid request. Each AllowedHeader can contain at most one wildcard (*) and cannot contain spaces.</p>
<p id="obs_04_0075__p34887463">Type: string</p>
<p id="obs_04_0075__p45551715">Ancestor: CORSRule</p>
</td>
</tr>
<tr id="obs_04_0075__row7312259"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p55422103">MaxAgeSeconds</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p60005388">Response time of CORS that can be cached by a client. It is expressed in seconds.</p>
<p id="obs_04_0075__p3177586">Each CORSRule can contain only one MaxAgeSeconds. It can be set to a negative value.</p>
<p id="obs_04_0075__p28598282">Type: Integer</p>
<p id="obs_04_0075__p56057947">Ancestor: CORSRule</p>
</td>
</tr>
<tr id="obs_04_0075__row34759480"><td class="cellrowborder" valign="top" width="28.28282828282828%" headers="mcps1.3.8.3.2.3.1.1 "><p id="obs_04_0075__p64054462">ExposeHeader</p>
</td>
<td class="cellrowborder" valign="top" width="71.71717171717171%" headers="mcps1.3.8.3.2.3.1.2 "><p id="obs_04_0075__p21028933">Indicates a supplemented header in CORS responses. The header provides additional information for clients. It cannot contain spaces.</p>
<p id="obs_04_0075__p55042672">Type: string</p>
<p id="obs_04_0075__p25622004">Ancestor: CORSRule</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="obs_04_0075__section24104539"><h4 class="sectiontitle">Error Responses</h4><p class="msonormal" id="obs_04_0075__p62116468"><a href="#obs_04_0075__table2262289217914">Table 2</a> describes possible special errors in this request.</p>
<div class="tablenoborder"><a name="obs_04_0075__table2262289217914"></a><a name="table2262289217914"></a><table cellpadding="4" cellspacing="0" summary="" id="obs_04_0075__table2262289217914" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Special error</caption><thead align="left"><tr id="obs_04_0075__row19846403"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.9.3.2.4.1.1"><p id="obs_04_0075__p64054849">Error Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.9.3.2.4.1.2"><p id="obs_04_0075__p21060291">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.9.3.2.4.1.3"><p id="obs_04_0075__p28162034">HTTP Status Code</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_04_0075__row66532277"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.9.3.2.4.1.1 "><p id="obs_04_0075__p20405365">NoSuchCORSConfiguration</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.9.3.2.4.1.2 "><p id="obs_04_0075__p42221849">Indicates that the CORS configuration of buckets does not exist.</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.9.3.2.4.1.3 "><p id="obs_04_0075__p64526602">404 Not Found</p>
</td>
</tr>
</tbody>
</table>
</div>
<p class="msonormal" id="obs_04_0075__p43868506">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_0075__section14482163815396"><h4 class="sectiontitle">Sample Request</h4><div class="codecoloring" codetype="Xml" id="obs_04_0075__screen8484163863919"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6</pre></div></td><td class="code"><div class="highlight"><pre><span></span>GET /?cors HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.example.com
Accept: */*
Date: WED, 01 Jul 2015 03:54:36 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:WJGghTrPQQXRuCx5go1fHyE+Wwg=
</pre></div>
</td></tr></table></div>
</div>
<div class="section" id="obs_04_0075__section76081155815"><h4 class="sectiontitle">Sample Response</h4><div class="codecoloring" codetype="Xml" id="obs_04_0075__screen8485113814"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27</pre></div></td><td class="code"><div class="highlight"><pre><span></span>HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: BF2600000164363593F10738B80CACBE
x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCSpngvwC5TskcLGh7Fz5KRmCFIayuY8p
Content-Type: application/xml
Date: WED, 01 Jul 2015 03:54:36 GMT
Content-Length: 825
<span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
<span class="nt">&lt;CORSConfiguration</span> <span class="na">xmlns=</span><span class="s">&quot;http://obs.region.example.com/doc/2015-06-30/&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;CORSRule&gt;</span>
<span class="nt">&lt;ID&gt;</span>783fc6652cf246c096ea836694f71855<span class="nt">&lt;/ID&gt;</span>
<span class="nt">&lt;AllowedMethod&gt;</span>POST<span class="nt">&lt;/AllowedMethod&gt;</span>
<span class="nt">&lt;AllowedMethod&gt;</span>GET<span class="nt">&lt;/AllowedMethod&gt;</span>
<span class="nt">&lt;AllowedMethod&gt;</span>HEAD<span class="nt">&lt;/AllowedMethod&gt;</span>
<span class="nt">&lt;AllowedMethod&gt;</span>PUT<span class="nt">&lt;/AllowedMethod&gt;</span>
<span class="nt">&lt;AllowedMethod&gt;</span>DELETE<span class="nt">&lt;/AllowedMethod&gt;</span>
<span class="nt">&lt;AllowedOrigin&gt;</span>obs.example.com<span class="nt">&lt;/AllowedOrigin&gt;</span>
<span class="nt">&lt;AllowedOrigin&gt;</span>www.example.com<span class="nt">&lt;/AllowedOrigin&gt;</span>
<span class="nt">&lt;AllowedHeader&gt;</span>AllowedHeader_1<span class="nt">&lt;/AllowedHeader&gt;</span>
<span class="nt">&lt;AllowedHeader&gt;</span>AllowedHeader_2<span class="nt">&lt;/AllowedHeader&gt;</span>
<span class="nt">&lt;MaxAgeSeconds&gt;</span>100<span class="nt">&lt;/MaxAgeSeconds&gt;</span>
<span class="nt">&lt;ExposeHeader&gt;</span>ExposeHeader_1<span class="nt">&lt;/ExposeHeader&gt;</span>
<span class="nt">&lt;ExposeHeader&gt;</span>ExposeHeader_2<span class="nt">&lt;/ExposeHeader&gt;</span>
<span class="nt">&lt;/CORSRule&gt;</span>
<span class="nt">&lt;/CORSConfiguration&gt;</span>
</pre></div>
</td></tr></table></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>