new WebResponse()
Represents the HTTP response currently being populated.
- See:
-
- $.request represents the corresponding request object.
Example
if($.request.method === $.net.http.GET) {
// get query parameter named id
var qpId = $.request.parameters.get("id");
// handle request for the given id parameter...
var result = handleRequest(qpId);
// send response
$.response.contentType = "plain/test";
$.response.setBody("result: " + result);
$.response.status = $.net.http.OK;
} else {
// unsupported method
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
Extends
Members
-
body :$.web.Body|undefined
-
The body of the response. The value is undefined when there is no body. Not available on $.response.
Type:
- $.web.Body | undefined
- Inherited From:
-
cacheControl :string
-
Easy access to the cache control header of the entity
Type:
- string
-
contentType :string
-
The content type of the entity
Type:
- string
- Inherited From:
-
cookies :$.web.TupelList
-
The cookies associated with the entity
Type:
-
entities :$.web.EntityList
-
The sub-entities of the entity
Type:
- Inherited From:
-
headers :$.web.TupelList
-
The headers of the entity
Type:
- Inherited From:
-
status :$.net.http
-
The HTTP status code of the outgoing HTTP response
Type:
Methods
-
followUp(object)
-
Enable running a follow up job that executes in the background.
Parameters:
Name Type Description object
$.web.WebResponse~followUpObject Object specifies script, function and optionally parameter of the follow up job. Throws:
Throws an error if the follow up job could not be accepted for execution.Example
$.response.followUp({ uri : "package:script.xsjs", functionName : "func", parameter : { a : "b" } });
-
setBody(body, index)
-
Sets the body of the entity; The method supports all elemental JavaScript types, ArrayBuffers, WebResponses and WebEntityResponses. When using WebResponse or WebEntityResponse as arguments, the headers identifying that the body is a WebResponse/WebEntityResponse (Content-Type: application/http, content-transfer-encoding: binary) are automatically added to the parent WebEntityResponse.
Parameters:
Name Type Argument Description body
any | ArrayBuffer | $.web.WebResponse | $.web.WebEntityResponse Can be any elemental JavaScript type, an ArrayBuffer, WebResponse or WebEntityResponse. index
Number <optional>
If the first argument is of type ResultSet, the number specifies the index of a Blob column. - Inherited From:
- See:
-
- $.web.Body.asWebRequest for an example on reading WebRequest objects from multipart request body and writing WebResponse objects to multipart response body.
Throws:
Throws an error if the given parameters cannot be used as a body.
Type Definitions
-
followUpObject
-
Type:
- object
Properties:
Name Type Argument Description uri
string uri absolute or relative path to the xsjs file to execute in the follow up job functionName
string name of the function parameter
object | string <optional>
parameter object or JSON string that will be passed to the function specified