查询http头配置接口

更新时间:2024-01-16 16:44:48

适用产品

网页加速、下载分发、全站加速、应用安全加速解决方案、IPv6一体化解决方案、电商安全加速解决方案、金融安全加速解决方案、政企安全加速解决方案、应用安全解决方案、区块链安全加速解决方案、IPv6安全加速解决方案、点播分发、直播分发、移动加速

接口描述

通过接口自助查询http头部配置。接口url的*可为域名名称或域名id。

调用频率

单用户调用频率:300/5min

推荐使用 Open API在线调试

Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试

请求参数

Path 参数

参数名称描述
*domain-nameString
需要查询配置的域名或域名id

返回参数

Body 参数

参数名称描述
domain-nameString
需要查询配置的域名或域名id
domain-idString
需要查询配置的域名或域名id
header-modify-rulesList
except-path-patternString
例外的url匹配模式,支持正则。 入参参考:
custom-patternString
匹配条件:指定常用类型,可选值为all或homepage 1、all:全部文件 2、homepage:首页
file-typeString
匹配条件:文件类型,多个请以英文;分隔,可选值: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
匹配条件:自定义文件类型,多个请以英文分号分隔。
directoryString
目录
specify-urlString
匹配条件:指定URL 入参不支持含http(s):// 开头的URI格式
request-methodString
匹配的请求方式,可选值为:GET、POST、PUT、HEAD、DELETE、OPTIONS,多个请以英文分号分隔
data-idNumber
添加grid类型标识,表示客户多组配置时,具体某组配置
path-patternString
url匹配模式,支持正则,如果是全部匹配,入参可以配置为:.*
header-directionString
http头的控制方向,可选值为cache2visitor/cache2origin/visitor2cache/origin2cache,单选。  cache2origin是指回源方向---对应配置项回源请求;  cache2visitor是指回客户端方向—对应配置项回客户端应答; visitor2cache是指接收客户端请求 origin2cache是指接收源应答
actionString
http头的控制类型,支持http头部值的增改删,可选值为add|delete|set,单选。对应header-name、header-value参数 add:新增头部 set:修改头部 delete:删除头部 注意:优先级顺序为delete>set>add
allow-regexpString
http头正则匹配,可选值:true/false。 true:表示对header-name的值按正则匹配方式处理 false:表示对header-name的值按实际入参处理,不做正则匹配。 不传默认是false
header-nameString
http头名称,新增或修改http头,只允许输入一个;删除http头允许输入多个,以分号“;”隔开。 注意:对特殊http头的操作是受限的,允许操作的http头及操作类型参看 此项为必填项,不能为空 当action为add:表示新增这个header-name头部 当action为set:修改这个header-name头部 当action为delete:删除这个header-name头部
header-valueString
http头域对应的值,例如:mytest.example.com 注意: 1、当action为add或set时,该入参必须传值 2、当action为delete时,该入参不用传 支持通过关键字获取指定变量值,如客户端ip,包含如下: 关键字:含义 #timestamp :当前时间,时间戳如1559124945 #request-host:请求头中的HOST #request-url :请求url,包含协议域名等的全路径,如http://aaa.aa.com/a.html #request-uri :请求uri,相对路径格式,如/index.html #origin-ip :回源IP #cache-ip :边缘节点IP #server-ip :对外服务IP #client-ip :客户端IP,即访客IP #response-header{xxx}:获取响应头中的值,如#response-header{etag},获取response-header中的etag值 #header{xxx}:获取请求的http header中的值,如#header{User-Agent},是获取header中的User-Agent值 #cookie{xxx}:获取cookie中的值,如#cookie{account},是获取cookie中设置的account的值  
request-headerString
匹配请求头,头部值支持正则,头和头部值用空格隔开,如:Range bytes=[0-9]{9,}
priorityString
表示客户多组配置的优先执行顺序。数字越大,优先级越高。 不传参默认为10,不可清空
except-file-typeString
例外的文件类型
except-directoryString
例外的目录
except-request-methodString
例外的请求方式
except-request-headerString
例外的请求头

示例

JSON
XML
JSON
请求示例
复制代码 复制成功
#!/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://open.chinanetcenter.com/api/config/headermodify/www.example.com" \
-X "GET" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-H "Content-Type:application/json"
返回示例
复制代码 复制成功
HTTP/1.1 200 OK
Date: Sun, 05 May 2019 09:08:53 GMT
Content-Type: application/json;charset=utf-8
x-cnc-request-id: 83bbebc7-2c95-47d7
{
    "domain-id":"123344",
    "domain-name":"www.example.com",
    "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}"
          },
                    {
                    "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"
          }
]
}
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!