<http-header>

HTTP request header definition

Core v2.2.0

Overview

The processor defines HTTP request headers for authentication, content type negotiation, custom headers, and API requirements. Must be used as a child element of .

Usage Examples

Example 1: API Authentication with Bearer Token

example-1.xml
<?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>

Example 2: Custom User-Agent

example-2.xml
<?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>

Example 3: Content-Type for POST requests

example-3.xml
<?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>

Example 4: Multiple custom headers

example-4.xml
<?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>

Parameters

Important Notes

Related Processors