Set HttpHeader
This interface is used to add or delete the http header of the specified accelerated domain name. The domain name shall belong to the user, otherwise it returns 403 failure.
Note: The interface is a full volume interface; when setting, the existing Header settings should be written together, or the original configuration is overrode.
Method | Path | Description |
---|---|---|
PUT | /v2/domain/{domain}/config?httpHeader | Modify or delete the forward-to-origin Header or response Header corresponding to the acceleration domain name |
Request body
Parameter | Optional | Type | Description |
---|---|---|---|
httpHeader | Required | HttpHeader | The set forward-to-origin or responded Header |
The HttpHeader structure is as follows
Parameter | Optional | Type | Description |
---|---|---|---|
type | Required | String | “origin” means this header takes effect when it forwards to origin, and “response” means it takes effect when it responds to the user. |
header | Required | String | header is an http header field. Generally, it is a standard Header of HTTP, or it can be a custom one by user, such as x-bce-authoriztion. |
value | Required | String | Assign the header value. A limited number of variables are supported. The substring starting with $ must have one of the modes that conform to ${x}, and x must be equal to one of the following strings: uri, host, scheme and request_uri. Typical invalid values: 1. The variable does not meet the limits requirements, such as "X-REQ-${url}", for there is no url in the valid variables we defined; 2. It contains the character $ but does not meet ${x} mode, such as: "X-REQ- $uri". Note value does not support the transmission of $ pure characters. If you want to respond to the client with a response header containing $, it will not be allowed. For example, "X-$" is invalid. |
action | Optional | String | It indicates whether to delete or add. You can select remove/add, and the default is add; the console only supports add action at present; API performs compatibility with the back-end remove configuration. |
describe | Optional | String | Description, optional, can be Chinese, uniformly use Unicode; the length should be no more than 100 characters |
Note
add origin header:Automatically add the specified http header to user’s request when forwarding to origin.
remove origin header:Specified http header is deleted automatically from the user requests while forwarding to origin.
add response header:Add designated http header automatically when responding to user's request.
remove response header:Automatically delete the specified http header when responding to user requests.
Response code (Http Status Code)
Http Status Code | Description |
---|---|
200 | Success |
Response body
Parameter | Type | Description |
---|---|---|
status | String | As the update action is an asynchronous call, the status returned after success is OPERATING, and the target status is RUNNING. |
Request example
PUT /v2/domain/myself.baidu.com/config?httpHeader HTTP/1.1
Host: myself.baidu.com
Content-Length: 145
Content-Type: application/json
{
"httpHeader":
[
{"type": "origin", "header": "x-auth-cn", "value":"xxxxxxxxx", "action": "add"},
{"type": "response", "header": "content-type", "value":"application/octet-stream", "action": "add"}
]
}
Response example
HTTP/1.1 200 OK
Content-Length: 31
Content-Type: application/json;utf-8
{
"status": "OPERATING|RUNNING"
}