Apama 10.3.1 | Apama Documentation | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The HTTP Server Transport Connectivity Plug-in | Mapping events between EPL and HTTP server requests
 
Mapping events between EPL and HTTP server requests
 
Distinguishing request types
Handling HTTP headers
Handling HTTP form decoding
Mapping the body
Dealing with cookies
Providing HTTP query parameters
Examples
The HTTP server can either be used as a general event submission API or as a general request/response API. A request to the HTTP server contains either a binary payload or a dictionary payload if the request had either an application/x-www-form-urlencoded or multipart/form-data content type. In the latter case, there will also be additional metadata fields. For the requests to be useful to EPL, they must be converted into the format expected by Apama. This is done using the Classifier codec, Mapper codec and other codecs (see Codec Connectivity Plug-ins). For request/response APIs, the same process is used in reverse to turn EPL events into the responses.
The event types used in EPL should be specific to your application and then mapped in the chain from the fields produced by the HTTP server. The following fields are created in each event by the HTTP server. Field names containing periods (.) indicate nested map structures within the metadata. This nesting is automatically handled by the Mapper codec, and fields can be referred to there just using these names (see also The Mapper codec connectivity plug-in).
The fields for requests from the transport to EPL are:
Field
Description
payload
The binary payload of the request.
metadata.requestId
A unique integer identifier which must be preserved in the response when using EPL-supplied responses.
metadata.contentType
The MIME type of the payload (string), taken from the first parameter of the HTTP Content-Type header, converted to lower case and with spaces trimmed off. See also Handling HTTP headers.
metadata.charset
The charset parameter of the Content-Type header (string), converted to lower case, with spaces trimmed off. See also Handling HTTP headers.
metadata.http.path
The path component (string) of the URI.
metadata.http.method
The HTTP method of the request: PUT, POST, GET, or DELETE.
metadata.http.user
When HTTP basic authentication is enabled, the authenticated user name (string).
metadata.http.cookies
A key-value map of cookies from the request (map). See also Dealing with cookies.
metadata.http.queryString
A key-value map of the options in the query-string component of the request URI (map). See also Providing HTTP query parameters.
metadata.http.headers
A key-value map of the HTTP headers sent by the request (map). Key names are converted to lower case regardless of original capitalization. See also Handling HTTP headers.
metadata.http.source
The address and port of the client connection which generated this request.
The fields for EPL-supplied responses are:
Field
Description
payload
The binary or dictionary payload of the response.
metadata.requestId
The requestId of the corresponding request. Must be correctly set in responses.
metadata.contentType
The MIME type of the payload (string). This is used to construct the HTTP Content-Type header. See also Handling HTTP headers.
metadata.charset
The charset of the payload, for text-format payloads. This is used to construct the HTTP Content-Type header. See also Handling HTTP headers.
metadata.http.statusCode
The HTTP status code (integer). Code 200 indicates success. Other codes should be used to indicate errors. Must be set in responses.
metadata.http.cookies
A key-value map of cookies to set on the client. See also Dealing with cookies.
metadata.http.headers
A key-value map of additional HTTP headers to send in the response. See also Handling HTTP headers.
metadata.http.form.name.contentType
The media type of the form data. See also Handling HTTP form decoding.
metadata.http.form.name.charset
The encoding of the form data. See also Handling HTTP form decoding.
metadata.http.form.name.filename
The filename of the form data. See also Handling HTTP form decoding.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.