HEADER (Dedicated)
The HEADER
element defines a custom header for an application or
service.
Syntax
<HEADER [
Method=http-method[
,...]
]
Name="header-name">header-value[
;...]
</HEADER>
Method
is an optional attribute. When set, the header is added in responses to requests for the HTTP operations listed. If theMethod
attribute is not specified, the header applies to all HTTP methods (the default behavior).- http-method must contain values that correspond to valid HTTP operations,
such as
GET
,OPTIONS
, and so on. This attribute can take a comma-separated list of HTTP operations. - header-name defines the unique identifier for the HTTP header.
- header-value is a value for the header. This attribute can take a semicolon-separated list of values.
Child elements
There are no child elements.
Usage
Use this element to define HTTP headers in applications and services defined in the GAS configuration file (as.xcf) and in external application and service configuration files.
You can configure several HEADER
elements to define custom headers that apply to
a specific application or service. These headers are always sent in the HTTP response unless the
Method
attribute is set to send the header in response to specified HTTP operations
only. If Method
is not specified, the header applies to all HTTP methods (the
default behavior).
The GAS sends these headers in addition to headers defined for all applications and services in
the HEADER (Common) elements
of the GAS configuration file. If the same HEADER
element is set in both the
application or service configuration file and the JGAS configuration file, the HEADER
defined in the
application or service configuration file is used; the JGAS configuration file is ignored.
Limitations
The headers defined in HEADER
elements of an application or service
configuration are not sent in the response of URLs for public resources, such as images
(/ua/i) and reports (/ua/report/). As these are public
URLs, the HEADER
defined for individual applications or services cannot be applied;
only the common HEADER
defined in the JGAS configuration file will apply.
The following examples outline how to configure the custom HTTP headers sent in HTTP responses for your application or service.
Example: Application configuration file with custom headers
<?xml version="1.0" encoding="UTF-8" ?>
<APPLICATION >
<PATH>$(res.deployment.path)</PATH>
<MODULE>myapp</MODULE>
</EXECUTION>
<HTTP>
<HEADER Name="Header_1">Hello</HEADER>
<HEADER Name="Header_2">World</HEADER>
<HEADER Name="Header_3">How</HEADER>
<HEADER Name="Header_4">Are</HEADER>
<HEADER Name="Header_5">You</HEADER>
</HTTP>
</APPLICATION>
Example: web service configuration file with custom headers
In this example, the "Access-Control-Allow-Origin" header is set with theMethod
attribute and will therefore only be sent when the request is received with
the HTTP OPTIONS
operation.<?xml version="1.0" encoding="UTF-8" ?>
<APPLICATION >
<EXECUTION ForwardOptionsRequest = "TRUE">
<ENVIRONMENT_VARIABLE Id="FGLWSDEBUG">0</ENVIRONMENT_VARIABLE>
<PATH>$(res.deployment.path)</PATH>
<MODULE>myservice</MODULE>
</EXECUTION>
<HTTP>
<HEADER Name="Header_1">Hello</HEADER>
<HEADER Name="Header_2">World</HEADER>
<HEADER Name="Header_3">How</HEADER>
<HEADER Name="Header_4">Are</HEADER>
<HEADER Name="Header_5">You</HEADER>
<HEADER Method="OPTIONS" Name="Access-Control-Allow-Origin"><https://foo.example</HEADER>
</HTTP>
</APPLICATION>
Parent elements
This element is a child of the HTTP (Dedicated) element.