SendResponse

Metreos.Providers.Http.SendResponse

Summary

SendResponse will send an HTTP response to a pending HTTP request.

Usage

In practical use, the SendResponse action is coupled with every occurrence of the GotRequest event, which is the event that corresponds to a pending HTTP request. The RemoteHost action parameter of SendResponse should always the same value as the RemoteHost event parameter of the GotRequest event in order for the response to be sent back to the correct request.

If one is sending back Cisco IP Phone XML as the Body of the response, note that the Cisco IP Phone XML variable must be passed in as a C# parameter, and the variable must have the ToString() method invoked on it, for instance, myXmlVar.ToString(). The Cisco IP Phone XML variable can not be passed in directly to the Body action parameter; it must be converted to a string before it is sent to the HTTP Provider. Also, be sure to set the Content-Type variable to the value text/xml if you are communicating with a Cisco IP Phone.

Remarks

One can specify custom action parameters for this action. Any custom action parameter is converted to a header in the HTTP response. For example, with this mechanism, one can send back a cookie by specifying a custom action parameter with the name Set-Cookie and the appropriate, cookie-formatted value.

Many web development environments allow one to specify a numeric value for the Expires header, which is treated as an offset in minutes of the current time. The HTTP Provider does not support this simple, numeric notion. The value of the Expires header is passed through directly to the HTTP response, requiring the developer to format the Expires header in conformance with the HTTP specification. One can use the System.DateTime class to generate this properly formatted string. For instance, a value for the Expires header that would indicate to the web client that the page is expired already could be DateTime.MinValue.ToUniversalTime().ToString("r").

One must use the SendResponse action within 5 minutes of receiving GotRequest; otherwise, the HTTP provider will send back a response automatically to the client with a response code of 404 and the script will have lost its opportunity to respond to the request.

Action Parameters
Parameter Name.NET TypeDefaultDescription
TimeoutSystem.Int32The Timeout property specifies to the Application Runtime Environment how long to wait for a response from the provider for the current action. The ReturnValue returned in this case is Timeout. The value must be a literal value in milliseconds.
ResponseCode *System.Int32The numeric code of the HTTP response, such as 200 for OK or 404 for Not Found.
ResponsePhraseSystem.StringThe response phrase of the HTTP response which corresponds to the ResponseCode, such as OK for 200 or Not Found for 404.
BodySystem.StringThe content of the response.
Content-TypeSystem.StringContent-Type describes the format of the Body, such as text/xml or text/html.
RemoteHost *System.StringThe IP address and port of the remote client, of the form IP:PORT. This correct value for this field is obtainable from the RemoteHost event parameter from the GotRequest event.

No Result Data

Branch Conditions 

Success

No description.

Failure

No description.

Timeout

No description.