IBM TDI provides a HTTP Server Connector that listens for incoming HTTP connections and acts like a HTTP server. Once it receives the request, it parses the request and sends the parsed request to the AssemblyLine workflow to process it. The result is sent back to the HTTP client. By default, the returned result has a content-type of "text/html".
The Connector supports Server and Iterator Modes. Server mode is the recommended mode:
If a Parser is specified then the Connector processes post requests and parses the contents using the specified Parser; get requests do not use the Parser. If a post request is received and no Parser is specified the contents of the post data is returned as an attribute (postdata) in the returned entry.
The HTTP Server Connector uses ibmdi.HTTP as internal Parser if no Parser is specified.
The HTTP Server Connector supports Server mode only.
The Connector parses URL requests and populates an entry in the following manner:
http://localhost:8888/path?p1=v1&p2=v2 http.method : 'GET' http.Host : 'localhost:8888' http.base : '/path' http.qs.p1 : 'v1' http.qs.p2 : 'v2'
http://localhost:8888/?p1=v1&p2=v2 http.method : 'GET' http.Host : 'localhost:8888' http.base : '/' http.qs.p1 : 'v1' http.qs.p2 : 'v2'
If a post request is used then it is expected that the requestor is sending data on the connection as well. Depending on the value for the Parser parameter the Connector performs the following actions:
The session with the HTTP client is closed when the Connector receives a getNext request from the AssemblyLine and there is no more data to fetch. For example, if the Parser has returned a null value, or on the second call to getNext if no Parser is present.
The HTTP Server Connector receives HTTP requests from HTTP clients and sends HTTP responses back. As mentioned above, the default content-type header is set to "text/html"; we can override that by setting the Entry attribute http.content-type to the appropriate value before the Connector returns the result to the client.
After the AssemblyLine initializes the HTTP Server Connector, it calls the getNextClient() method of the Connector. This method blocks until a client request arrives. When a request is received (and Server Mode is selected), the Connector creates a new instance of itself, which is handed over to the AssemblyLine that subsequently spawns a new AssemblyLine thread for that Connector instance. This design feature provides the ability to process each Event in a separate thread, which allows the HTTP Server Connector to process several HTTP events in parallel. The AssemblyLine then calls the getNextEntry() method on this new Connector instance in the new thread. Each Entry returned by the getNextEntry() call represents an individual HTTP request from the HTTP client. The Connector's replyEntry(Entry conn) method is called for each Entry returned from getNextEntry() to send to the client the corresponding HTTP response.
The parameter HTTP Basic Authentication governs whether client authentication will be mandated for HTTP clients accessing this connector over the network.
There are two different ways to implement HTTP Basic Authentication with the HTTP Server Connector:
This is a mechanism for backward compatibility with the old HTTP EventHandler (which is no longer present in TDI 7.1). A connector parameter Auth Connector specifies a TDI Connector that will be used in Lookup Mode, with the username and password for the HTTP Basic Authentication data specified as the Link Criteria:
This mechanism requires a certain amount of coding, but provides more power and lets you implement authentication through our own scripting. It can only be used when the Auth Connector parameter is NULL or empty.
The Connector will make available to you the username and password values in the "After Accepting connection" Hook through the getUserName() and getPassword() public Connector methods. It is now your responsibility to implement the authentication mechanism. You should call the Connector's rejectClientAuthentication() method from the AssemblyLine hook if authentication is not successful. Consider the following example authentication script code:
var httpServerConn = conn.getAttribute("connectorInterface").getValue(0); var username = httpServerConn.getUserName(); var password = httpServerConn.getPassword(); //perform verification here successful = true; if (!successful) { httpServerConn.rejectClientAuthentication(); }
When the parameter Chunked Transfer Encoding is enabled, the Connector will write the HTTP body as series of chunks.
When chunked encoding is used, you are responsible for calling the Connector's putEntry(entry) method for each chunk - the value of the "http.body" Attribute of the Entry provided will be sent as an HTTP chunk. The replyEntry(entry) Connector's method is automatically called by the AssemblyLine at the end of the iteration - it will write the last chunk of data (if the "http.body" Attribute is present) and close the chunk sequence.
When a Parser is specified to the HTTP Server Connector, it will be the stream returned by the Parser that will be sent as a HTTP chunk on each putEntry(entry) or replyEntry(entry) call.
The Connector needs the following parameters:
When this parameter is specified, the HTTP Server Connector will issue authentication requests to any client (for example, a Web browser) that tries to access this service and does not provide authentication data. When the client provides the username/password the HTTP Server Connector will call the Authenticator Connector's lookup method providing the username and password attributes. Hence, the authentication Connector must be configured using a Link Criteria where the $username and $password attributes are used. A typical link criteria would be:
username equals $username password equals $password
If the search fails, the HTTP Server Connector denies the request and sends an authentication request back to the client. If the search succeeds, the HTTP Server Connector processes the request.
The entry returned by the authenticator Connector can be accessed through the "auth.entry" Property of the event Entry.
For more details on client authentication, and for an alternative method to using an Auth Connector, see Connector Client Authentication.
When SSL is used, the Connector will use the default TDI Server SSL settings - certificates, keystore and truststore.
We can select a Parser from the Parser configuration pane; click on the Inherit from: button in the bottom right corner when the Parser pane is active.
Listed below are all the Attributes supported by the HTTP Server Connector.
URL Connector,
HTTP Client Connector,
HTTP Parser.