HTTP request header definition
Core v2.2.0
The
processor defines HTTP request headers for authentication,
content type negotiation, custom headers, and API requirements. Must be used as a child element of
.
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="apiKey">sk_live_abc123xyz</def>
<http url="https://api.example.com/data">
<http-header name="Authorization">Bearer ${apiKey}</http-header>
<http-header name="Accept">application/json</http-header>
</http>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<http url="https://example.com/page">
<http-header name="User-Agent">Mozilla/5.0 (compatible; MyBot/1.0)</http-header>
<http-header name="Accept-Language">en-US,en;q=0.9</http-header>
</http>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<http url="https://api.example.com/users" method="POST">
<http-header name="Content-Type">application/json</http-header>
<http-header name="Authorization">Bearer ${apiKey}</http-header>
{"name": "John", "email": "john@example.com"}
</http>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<http url="https://api.example.com/v1/data">
<http-header name="X-API-Key">${apiKey}</http-header>
<http-header name="X-Request-ID">${requestId}</http-header>
<http-header name="X-Client-Version">2.2.0</http-header>
<http-header name="Accept">application/json</http-header>
<http-header name="Accept-Encoding">gzip, deflate</http-header>
</http>
</config>
element