设置自定义HTTP头配置
更新时间:2026-06-05
接口
本接口用于设置站点的自定义 HTTP 头配置。
注意:此接口为全量接口,设置时需要将已有的Header设置也要一并写入,否则原有配置会被覆盖。
请求接口
| Method | Path | 说明 |
|---|---|---|
| PUT | /v2/geo/site/{site}/config | 设置自定义 HTTP 头配置接口 |
site:表示要设置的站点。
请求体
| 参数 | 类型 | 可选 | 说明 |
|---|---|---|---|
| httpHeader | List<HttpHeader> | 必选 | 自定义 HTTP 头配置。 |
响应码
| HTTP Status Code | 说明 |
|---|---|
| 200 | 设置自定义 HTTP 头配置成功 |
| 其他错误码 | 配置参数错误 |
响应体
| 参数 | 类型 | 说明 |
|---|---|---|
| status | String | 表示修改该配置的状态。设置配置成功,其值为“RUNNING”。否则返回报错信息。 |
请求示例1:设置HTTP头
Plain Text
1PUT /v2/geo/site/test.com/config HTTP/1.1
2Host: geo.baidubce.com
3Content-Length: 46
4Authorization: xxx
5Content-Type: application/json;charset=utf-8
6Accept-Encoding: gzip
7
8{
9 "httpHeader": [
10 {
11 "type": "response",
12 "header": "Cache-Control",
13 "value": "test",
14 "action": "add"
15 },
16 {
17 "action": "add",
18 "type": "origin",
19 "header": "Expires",
20 "value": "test"
21 }
22 ]
23}
请求示例2:删除HTTP头
Plain Text
1PUT /v2/geo/site/test.com/config HTTP/1.1
2Host: geo.baidubce.com
3Content-Length: 46
4Authorization: xxx
5Content-Type: application/json;charset=utf-8
6Accept-Encoding: gzip
7
8{
9 "httpHeader": [
10 {
11 "type": "response",
12 "value": "",
13 "action": "remove",
14 "header": "Expires"
15 },
16 {
17 "value": "",
18 "type": "origin",
19 "action": "remove",
20 "header": "Cache-Control"
21 }
22 ]
23}
响应示例
Plain Text
1HTTP/1.1 200 OK
2Server: nginx/1.16.1
3Content-Type: application/json; charset=utf-8
4Transfer-Encoding: chunked
5Connection: keep-alive
6
7{
8 "status": "RUNNING"
9}
评价此篇文章
