HTTP请求

HTTP配置块在mapcache配置中的多个位置使用。

指定URL

最简单的HTTP配置块需要一个`<url>`子元素:

<http>
  <url>http://server/path?key=value</url>
</http>

超时

您可以配置超时,在超时之后放弃HTTP请求:

<http>
  <url>http://server/path?key=value</url>

  <!-- timeout in seconds to wait while establishing a connection. This may be needed for
  firewalled MapCache or HTTP instances -->
  <connection_timeout>30</connection_timeout>

  <!-- total maximum time allowed for the whole request. Includes the time needed to
 transfer data down the wire -->
  <timeout>60</timeout>
</http>

报头

您可以在请求中插入自定义头,或者转发从客户端请求接收的头:

<http>
  <url>http://server/path?key=value</url>
  <headers>
    <User-Agent>My MapCache User-Agent</User-Agent>   <!-- hard coded header -->
    <X-My-Forwarded-Header>{X-Received-Header}<X-My-Forwarded-Header> <!-- Forwarded from client, optionally changing the header name -->
    <X-My-Forwarded-Header-2>foobar-{X-Received-Header}-baz<X-My-Forwarded-Header-2> <!-- Forwarded and modified from client, optionally changing the header name -->
  </headers>
</http>