.TH mod_esi 3erl "inets 5.10.3" "Ericsson AB" "Erlang Module Definition" .SH NAME mod_esi \- Erlang Server Interface .SH DESCRIPTION .LP This module defines the Erlang Server Interface (ESI) API\&. It is a more efficient way of writing erlang scripts for your Inets web server than writing them as common CGI scripts\&. .SH EXPORTS .LP .B deliver(SessionID, Data) -> ok | {error, Reason} .br .RS .LP Types: .RS 3 SessionID = term() .br Data = string() | io_list() | binary() .br Reason = term() .br .RE .RE .RS .LP This function is \fIonly\fR\& intended to be used from functions called by the Erl Scheme interface to deliver parts of the content to the user\&. .LP Sends data from a Erl Scheme script back to the client\&. .LP .RS -4 .B Note: .RE Note that if any HTTP-header fields should be added by the script they must be in the first call to deliver/2 and the data in the call must be a string\&. Calls after the headers are complete may contain binary data to reduce copying overhead\&. Do not assume anything about the data type of SessionID, the SessionID must be the value given as input to the esi call back function that you implemented\&. .RE .SH "ESI CALLBACK FUNCTIONS" .SH EXPORTS .LP .B Module:Function(SessionID, Env, Input)-> _ .br .RS .LP Types: .RS 3 SessionID = term() .br Env = [EnvironmentDirectives] ++ ParsedHeader .br EnvironmentDirectives = {Key,Value} .br Key = query_string | content_length | server_software | gateway_interface | server_protocol | server_port | request_method | remote_addr | script_name .br Input = string() .br .RE .RE .RS .LP The \fIModule\fR\& must be found in the code path and export \fIFunction\fR\& with an arity of three\&. An erlScriptAlias must also be set up in the configuration file for the Web server\&. .LP If the HTTP request is a \&'post\&' request and a body is sent then content_length will be the length of the posted data\&. If \&'get\&' is used query_string will be the data after \fI?\fR\& in the url\&. .LP ParsedHeader is the HTTP request as a key value tuple list\&. The keys in parsed header will be the in lower case\&. .LP SessionID is a identifier the server uses when \fIdeliver/2\fR\& is called; do not assume anything about the datatype\&. .LP Use this callback function to dynamically generate dynamic web content\&. When a part of the page is generated send the data back to the client through \fIdeliver/2\fR\&\&. Note that the first chunk of data sent to the client must at least contain all HTTP header fields that the response will generate\&. If the first chunk does not contain the \fIEnd of HTTP header\fR\&, that is \fI"\\r\\n\\r\\n",\fR\& the server will assume that no HTTP header fields will be generated\&. .RE .LP .B Module:Function(Env, Input)-> Response .br .RS .LP Types: .RS 3 Env = [EnvironmentDirectives] ++ ParsedHeader .br EnvironmentDirectives = {Key,Value} .br Key = query_string | content_length | server_software | gateway_interface | server_protocol | server_port | request_method | remote_addr | script_name\&. .br Input = string() .br Response = string() .br .RE .RE .RS .LP This callback format consumes a lot of memory since the whole response must be generated before it is sent to the user\&. This function is deprecated and only kept for backwards compatibility\&. For new development Module:Function/3 should be used\&. .RE