com.HTTPServiceRequest.sendTextResponse

Sends and HTTP response with data from a plain string.

Syntax

sendTextResponse(
   code INTEGER,
   desc STRING,
   data STRING )
  1. code is the status code of the response.
  2. desc is the description of the response.
  3. data is the string containing the data to be sent.

Usage

The sendTextResponse() method performs the HTTP response by sending the a status (code) and description (desc), followed by the headers previously set, and text data contained in the string as body.

If the request failed to be read, its content will be discarded; for example, when a request is not well formatted.

The default Content-Type header is text/plain, but it can be changed if of the form */*. For example: application/json.

Automatic conversion from locale to user-defined charset is performed when possible, otherwise throws an exception.

In HTTP 1.1, if the body size is greater than 32k, the response will be sent in several chunks of the same size.

If the description is NULL, a default description according to the status code is sent.

The body of the request is discarded.

New incoming requests can be retrieved again with the com.WebServiceEngine.GetHTTPServiceRequest() method.

In case of error, the method throws an exception and sets the STATUS variable with the appropriate error number.