Service: response

response

Web-apps only

Controls the response to the current HTTP request. Accessed via the global variable response. This variable is only available when the script has been invoked by a HTTP request.

Members

(static) contentType :String

HTML Content-Type of the response.

Type:
  • String

(static) downloadFile :String

Path of file that the client will download. If this property is set to a value other than null then the response will be to have the client download the file with the given virtual file-system path.

Type:
  • String

(static) downloadName :String

File-name provided to the browser for the downloadFile.

Type:
  • String

(static) forceDownload :Boolean

Should the client be forced to download the file (as opposed to possibly rendering it in the browser)? If this property is set to true then "content-disposition" field will be set in the HTTP header, which is usually interpreted by the browser to mean that the response will be saved to a file rather than rendered in the browser.

Type:
  • Boolean
Default Value:
  • false

(static) headers :Object

Provides access to the headers of the response. The names of the fields of the returned object are those of the headers.

Method:

  • add(name, value) adds a header field with the given name and value.
Type:
  • Object

(static) nextScriptPath :String

Path of script to execute next. Continue processing of the current request by executing the script at nextScriptPath.

Type:
  • String

(static) previousScriptPath :String

Path of previous script that was executed. Scripts can be chained together by means of the nextScriptPath property. The value of previousScriptPath is the path of the previous script executed or null if no previous script was executed.

Type:
  • String

(static) redirectUrl :String

URL to redirect to. If redirectUrl is set then the client will be redirected to the specified URL.

Type:
  • String

Methods

(static) write(text)

Write the given text to the body of the response.

Parameters:
Name Type Description
text String

Text to write to the response.

(static) writeUsingTemplateFile(templateFilePath, data)

Apply the given data to the template in the given file and write the result to the response. The template engine can also be accessed via the Templater.renderFile method, which doesn't write to the response.

Parameters:
Name Type Description
templateFilePath String

Path to template file.

data Object

Object containing values to substitute into the template.

(static) writeUsingTemplateString(template, data)

Apply the given data to the given template and write the result to the response. The template engine can also be accessed via the Templater.renderString method, which doesn't write to the response.

Parameters:
Name Type Description
template String
data Object

Object containing values to substitute into the template.