Media Acceleration VoD,Media Acceleration Live Broadcast,Content Acceleration,Dynamic Web Acceleration
Through the interface self-implementation http header additions and deletions to the function, can be achieved in the cdn layer of personalized http header control, so that customers do not need to modify the source stationin this case, a custom http header and speedup are implemented. The interface * can be domain name or domain id.
Single user trigger frequency: 300/5min
| Name | Description |
|---|---|
*domain-nameString | the domain whoes need query config |
| Name | Description |
|---|---|
*header-modify-rulesList | Http header settings
note:
1. When you need to cancel the http header setting, you can pass in the empty node |
data-idLong | Add a grid type identifier to indicate a specific set of configuration when the customer has multiple sets of configurations.
The data-id can be obtained through a query interface.
Note: Add a grid type identifier: data-id. Each set of configurations corresponds to a data-id:
a. If the customer provides a data-id, it means they are specifying to modify the content of a particular set of configuration items. There is no need to include parameters for other sets of configurations that do not require modification.
b. If the customer provides multiple sets of configurations in the input parameters, and some sets include a data-id while others do not, then those with a data-id indicate modification of a specific set of configurations. Those without a data-id indicate adding a new set of configurations on top of the existing ones.
c. If none of the customer's input parameters include a data-id, it means the current configurations will be fully overwritten with the configurations provided this time.
d. If the customer does not provide any configuration item parameters in the input, and only provides the domain name and secondary label, it means clearing all configurations for the domain's secondary service corresponding to this interface. (The content of points c and d is consistent with the current implementation plan.)
e. The input parameters under a grid tag cannot be empty. If there are no specific configuration items, the data-id must be provided, and its value must correspond to an existing data-id, indicating that the values of the configuration items corresponding to this data-id will be cleared. |
path-patternString | The url matching mode supports fuzzy regularization. If all matches, the input parameters can be configured as: |
except-path-patternString | Exception url matching pattern, support regular. Example: |
custom-patternString | Matching conditions: specify common types, optional values are all or homepage. 1. all: all files 2. homepage: home page |
file-typeString | Matching conditions: file type, please separate by semicolon, optional values: gif png bmp jpeg jpg html htm shtml mp3 wma flv mp4 wmv zip exe rar css txt ico js swf m3u8 xml f4m bootstarp ts. |
custom-file-typeString | Matching condition: Custom file type, separate by semicolon. |
directoryString | Directory |
specify-urlString | Matching Condition: Specify URL.
The input parameter does not support the URI format starting with http(s):// |
request-methodString | The matching request method, the optional values are: GET, POST, PUT, HEAD, DELETE, OPTIONS, separate by semicolons. |
header-directionString | The control direction of the http header, the optional value is cache2visitor/cache2origin/visitor2cache/origin2cache, single-select.
Cache2origin refers to the source direction---corresponding to the configuration item return source request;
Cache2visitor refers to the direction of the client back - the corresponding configuration item returns to the client response;
Visitor2cache refers to receiving client requests
Origin2cache refers to the receiving source response |
actionString | The control type of the http header supports the addition and deletion of the http header value. The optional value is add|set|delete, which is single-selected. Corresponding to the header-name and header-value parameters.
1. Add: add a header
2. Set: modify the header value
3. Delete: delete the header
Note: priority is delete > set > add |
allow-regexpString | Http header regular match, optional value: true / false.
True: indicates that the value of the header-name is handled as a regular match.
False: indicates that the value of the header-name is processed according to the actual parameters, and no regular match is made.
Do not pass the default is false |
header-nameString | Http header name, add or modify the http header, only one is allowed; delete the http header to allow multiple entries, separated by a semicolon ';'.
Note: The operation of the special http header is limited, and the http header and operation type of the operation are allowed.
This item is required and cannot be empty
When the action is add: indicates that the header-name header is added.
When the action is set: modify the header-name header
When the action is delete: delete the header-name header |
header-valueString | The value corresponding to the HTTP header field, for example: mytest.example.com
Note:
1. When the action is add or set, the input parameter must be passed a value
2. When the action is delete, the input parameter is not passed
Support to get the value of specified variable by keyword, such as client IP, including:
Key words: meaning
#timestamp: current time, timestamp as 1559124945
#request-host: host in the request header
#request-url: request url, which contains the full path of the protocol domain name, etc., such as http://aaa.aa.com/a.html
#request-uri: request uri, relative path format, such as /index.html
#origin- IP: return source IP
#cache-ip: edge node IP
#server-ip: external service IP
#client-ip: client IP, or visitor IP
#response-header{XXX} : get the value in the response header, such as #response-header{etag}, get the etag value in response-header
#header{XXX} : to get the value in the HTTP header of the request, such as #header{user-agent}, is to get the user-agent value in the header
#cookie{XXX} : get the value in the cookie, such as #cookie{account}, is to get the value of the account set in the cookie |
header-value-oldString | The original value corresponding to the HTTP header field |
request-headerString | Match request header, header values support regular, header and header values separated by Spaces, e.g. : Range bytes=[0-9]{9,} |
priorityString | Indicates the priority of execution order for multiple sets of configurations. A higher number indicates higher priority. If no parameters are passed, the default value is 10 and cannot be cleared. |
except-file-typeString | Exception file type. |
except-directoryString | Exception directory. |
except-request-methodString | Exception request method. |
except-request-headerString | Exception request header. |
overrideString | HTTP Header Override Option, Values: true/false/.Empty string true: If the specified header already exists, the original header will be overwritten. If the header does not exist, a new header will be added. false: If the specified header already exists, the original header remains unchanged. If the header does not exist, a new header will be added. Empty string: indicating to clear the configuration Note: This override operation only applies to the cache2origin and cache2visitor directions. |
uaString | User-Agent, multiple values separated by vertical bar (|) |
except-uaString | Exceptional User-Agent, multiple values separated by vertical bar (|) |
status-codeString | HTTP Status Code, multiple values separated by semicolons (;) |
except-status-codeString | Exceptional HTTP Status Code, multiple values separated by semicolons (;) |
except-custom-file-typeString | Exception Custom File Type, multiple values separated by semicolons (;) |
response-headerString | Response Headers, e.g.: cache-control max-age=, multiple values not allowed |
except-response-headerString | Exceptional Response Headers, e.g.: cache-control max-age=, multiple values not allowed |
descriptionString | description |
| Name | Description |
|---|---|
httpStatusInteger | httpstatus=202; Indicates that the new domain API was successfully invoked, and the current deployment of the new domain can be viewed using x-cnc-request-id in the header |
x-cnc-request-idString | Uniquely identified id for querying tasks per request (for all API) |
locationString | The URL used to access the domain information, where domain-id is the unique token generated by our cloud platform for the domain name and whose value is a string. |
codeString | Error code, which appears when HTTPStatus is not 202, represents the error type of the current request call |
messageString | Response information, success when successful |
| Error code(code) | Description(message) | HTTP status | Semantic |
|---|---|---|---|
| InvalidParameter | All other properties are null, and the dataId cannot be null | 400 | All other properties are null, and the dataId cannot be null |
| InvalidParameter | Header-modify-rules field does not exist | 400 | Header-modify-rules field does not exist |
| InvalidParameter | Path-pattern field does not exist | 400 | Path-pattern field does not exist |
| InvalidParameter | Header-direction field does not exist | 400 | Header-direction field does not exist |
| InvalidParameter | Header-direction illegal | 400 | Header-direction illegal |
| InvalidParameter | Header-name field does not exist | 400 | Header-name field does not exist |
| InvalidParameter | Header-name is greater than 1 when the operation is new or modified | 400 | Header-name is greater than 1 when the operation is new or modified |
| InvalidParameter | Action field does not exist | 400 | Action field does not exist |
| InvalidParameter | Action field is illegal | 400 | Action field is illegal |
| InvalidParameter | AllowReg field is not legal | 400 | AllowReg field is not legal |
| InvalidParameter | When the action is add or set, the input must pass a value | 400 | When the action is add or set, the input must pass a value |
| InvalidParameter | When the action is delete, the entry does not need to be passed | 400 | When the action is delete, the entry does not need to be passed |
| HeaderDirectionError | The corresponding direction (header-direction) of your customized header (header-name) can only be {0}. {0} see the actual response value of the interface. | 400 | The corresponding direction (header-direction) of your customized header (header-name) can only be {0}. {0} see the actual response value of the interface. |
| ConfigError | Pick one of the following items: exceptional url mode, exception directory, exception file type - exception custom file type | 400 | Pick one of the following items: exceptional url mode, exception directory, exception file type - exception custom file type |
| ConfigError | Priority must be an integer not exceeding 7 digits | 400 | Priority must be an integer not exceeding 7 digits |
| ConfigError | Priority is required.\n | 400 | Priority is required.\n |
| InvalidParameter | When the action is add or delete, the entry does not need to be passed | 400 | When the action is add or delete, the entry does not need to be passed |
#!/bin/bash
username="example_username"
apiKey="example_apiKey"
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
curl -i --url "https://{@apiDomain}/api/config/headermodify/123344" \
-X "PUT" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-d '
{
"header-modify-rules": [
{
"path-pattern": ".*",
"request-header": "My-Http-Header .",
"header-direction": "cache2visitor",
"action": "add",
"header-name": "My-Http-Header",
"header-value": "#header{My-Http-Header}",
"override":"true"
},
{
"path-pattern": "/def",
"header-direction": "cache2visitor",
"action": "set",
"header-name": "Server",
"header-value": "my_new_value"
},
{
"path-pattern": "/abc",
"header-direction": "cache2visitor",
"action": "delete",
"header-name": "Via"
}
],
"description": "description"
}'HTTP/1.1 202 Accepted
Date: Fri, 17 May 2017 06:33:26 GMT
Content-Type: application/json;charset=utf-8
x-cnc-request-id:c54cbbb4-19fe-407a-930c-3988b62ed2fd
{"message":"success"}