The HTTP Server Functions allow you to create an HTTP server host and to handle incoming HTTP server requests. REST API is supported by this Function.
There are two types of HTTP Server Functions available in Usage Engine:
HTTP Server Collector
Select this Function to create an HTTP server host. Enter the following details:
Hosting Settings option | Description |
---|---|
URL path | Enter your URL path in the format of /myurl ., a full URL needs to be typed in, including the opening protocol (HTTP or HTTPS). This path is included in the private URL that is generated for you to copy and share. Including parameters in the URL path is supported. |
Select HTTP request method(s) | You can select several HTTP request methods if required, but you must select at least one. If you select HTTP POST, it must contain body. |
Username | Username to access the HTTP server |
Password | Password to access the HTTP server |
Connection timeout after | Enter after how many seconds the server closes a request and a 500 Server Error is sent back to the client. The default is 5 seconds. |
HTTP Server one-way | Select the checkbox if you do not require a response to be sent to the HTTP request If you require a response to be sent towards the HTTP request, leave the HTTP Server one-way check box empty in the configuration. Note! You must have an HTTP Server forwarder in your stream to send responses to the HTTP Client. |
Custom OPTIONS Method | Select this checkbox to set custom headers for the OPTIONS requests. This opens a Key/Value input field that allows users to set their desired content. Click on the +Header button to enter additional fields. Note! When this option is selected the access-control-allow-origin header value can be changed by the user. If no custom value is provided for this header, the value will be set to "*". |
The HTTP status code 429 is sent in case the number of requests exceeds this limit. The HTTP Server collector can handle up to 20 requests per second.
Supported Content-Type Formats
Currently, the following content type formats are supported:
- application/json
- application/x-www-form-urlencoded
- text/plain
- text/xml
- application/xml
application/cloudevents+json
application/cloudevents-batch+json
Specific Content-Type Data Handling
The HTTP Server Function processes content-type and methods in accordance with built-in rules:
- POST and PUT — Empty content-type requests will be rejected and a "415 - Unsupported Media Type" code will be returned as a result.
- GET and DELETE — If the content-type is present and the content length is bigger than a value of “0”, then the data will be parsed and processed. If no content-type is present the body will not be parsed. In case the content-length is not specified a “411 Length Required” error message will be returned.
Note!
- A URL is generated in Ingress that is used for communicating with the HTTP server.
- The HTTP server can only accept up to 1MB Content-Length.
- When a non-supported content type is specified, the following error will be displayed:
An error occurred while receiving a ${method} request: `Invalid content-type specified: ${contentType}`
Storing data in memory
Storing data in memory is not encouraged as any stream abortion will automatically delete the buffered information. In addition, any maintenance activities on an infrastructure level might require a stream restart which may cause memory loss if any data is stored in the memory.
HTTP Server Forwarder
Select this Function to create and send an HTTP Server response. All input values are set to the default entries when the node is placed on the Stream Editor.
The available options are divided into two sections. The first section shows the selected reader from which the HTTP stream will be taken. If several readers are placed on the Stream Editor, a drop-down menu enables the users to make a selection.
Settings | Description |
---|---|
Select Request Node | Select the HTTP Server collector you want to connect to the HTTP Server forwarder. |
Status Code | This input field allows custom entry. The default value is 200. Users can set their own code in relation to the end result. |
Header | This section is used to define response headers such as Content-Type and others, to set up the configuration. Any content type can be used, the default option is application/json. |
Body | This input field enables the user to enter the content for the Body. The HTTP Server Function does not validate the input information. Hence, the entered data must be verified manually. |
Headers Security Considerations
Setting up HTTP headers in the forwarder is done in accordance with the built-in security considerations that limit some of the input.
There are forbidden headers that cannot be entered into the service:
- location
- host
- x-forwarded-host
- x-forwarded-for
- x-host
- x-http-host-override
- set-cookie
Values that are entered in place of the forbidden ones will be rejected.
Some HTTP headers have predefined values and cannot be replaced:
- access-control-allow-credentials
- access-control-allow-headers
- access-control-allow-methods
- access-control-allow-origin
- connection
- content-length
- date
Values that are entered in place of the default ones will be ignored.