【发布时间】:2019-04-25 14:58:39
【问题描述】:
我对 Azure API 管理很陌生,我正在尝试使用策略检查或打印我在 Azure API 管理中的 API 调用的 HTTP 请求标头“主机”。
HTTP 头响应:
请求标头:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7,nl;q=0.6
Cache-Control: max-age=0
Cookie: __utma=124807636.1965218888.1554190818.1554190818.1554190818.1;
__utmc=124807636; __utmz=124807636.1554190818.1.1.utmcsr=google|utmccn=
(organic)|utmcmd=organic|utmctr=(not%20provided); __utmt=1;
__utmb=124807636.4.10.1554190818
Host: api.openweathermap.org
Proxy-Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
这是我迄今为止尝试过的:
<policies>
<inbound>
<check-header name="Host" failed-check-httpcode="401" failed-check-error-message="Not JSON" ignore-case="false">
<value>api.openweathermap.org</value>
</check-header>
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
希望有人能提供帮助。
提前致谢!
【问题讨论】:
-
取决于您如何定义“打印”。 APIM 接收请求,将其传递给后端,接收响应,将其传递给客户端。除了将其放入响应或跟踪之外,没有太多“打印”任何东西的方式,仅在请求时才收集。那么你到底想做什么呢?
标签: azure api validation http-headers azure-api-management