Object Reply

Reflects the reply that this script has sent (or will send).

object Reply

more...

Summary

reasonDescriptive http reply reason.
sentTrue when the header has been delivered, false if the header is still unsent.
statusNumeric HTTP reply code.
clearCookie()Remove given cookie.
commit()Sends immediately the header and pending data.
ctype()Helper creating a Content-Type header.
getHeader()Retrieves the value of a given header.
getHeaders()returns the list of headers that will be sent (or have been sent).
redirect()Helper creating a Refresh (redirection) header.
setCookie()sets a cookie that will be received next time that a script is called.
setHeader()Adds or remove a reply header.

Detailed description

object Reply


Reflects the reply that this script has sent (or will send).

This object contains the header that the system is going to send back to the remote client as soon as the first output (through the ">" operator or through print functions) is performed. If output has already been performed, then the header becomes read-only, and the Reply.sent field becomes true.

Falcon template files willing to change the output header should escape to Falcon immediately, giving the escape sequence as their very first character, as unescaped text is immediately sent to the upstream server.

A suitable default header with "+200 OK", no cache pragmas and text/html in utf-8 encoding is provided by default.

Properties

reason

Descriptive http reply reason.

sent

True when the header has been delivered, false if the header is still unsent.

status

Numeric HTTP reply code.

Methods

clearCookie()

Remove given cookie.

Reply.clearCookie( name )

nameThe cookie to be removed.

This function explicitly tries to clear the cookie from the remote client cache. The cookie value is not removed from the Request.cookies array.

commit()

Sends immediately the header and pending data.

Reply.commit( )

Usually, the integration module sends the header upstream at a reasonable moment, but some scripts may prefer to send the header sooner; in example, this is useful if the script is just generating a reply that consists in an HTTP header without data, or to start a keep-alive HTTP/1.1 conversation.

ctype()

Helper creating a Content-Type header.

Reply.ctype( type, [subtype], [charset] )

typeMain MIME type of the data that shall be sent to output.
subtypeMIME Subtype that shall be sent to the output.
charsetMIME Charset encoding of the output (if text).

Creates a Content-Type: <type>/<subtype>; charset=<charset> field in the headers. It's just a shortcut.

Note: Many functions in the module suppose that the output will be utf-8.

getHeader()

Retrieves the value of a given header.

Reply.getHeader( name )

nameThe name of the header to be queried.
Returns:If the header is set, its value as a string; false otherwise.

The header name is automatically capitalized at the beginning and after each '-' symbol.

Note: Pay attention to the fact that the maps in which headers are stored are case-sensitive.

getHeaders()

returns the list of headers that will be sent (or have been sent).

Reply.getHeaders( )

Returns:A dictionary of strings containing all the headers prepared for being sent.

This method returns a map containing all the headers that the WOPI system is going to send, or that have been sent if output is already started.

The map is a snapshot of the current status of the Reply. Headers can be manipulated only through Reply.setHeader. Any change to this structure won't be reflected on the actual reply headers, and similarly, any change in the Reply headers will not be reflected into this value.

redirect()

Helper creating a Refresh (redirection) header.

Reply.redirect( [uri], [timeout] )

uriWhere to redirect the page.
timeoutNumber of seconds before refresh takes place.

This function creates a well-formed "Refresh" header in the reply, which can:

Note: As this method mangles the output headers, it must be called before any output is sent to the client. Otherwise, it will be ignored.

setCookie()

sets a cookie that will be received next time that a script is called.

Reply.setCookie( name, [value], [expires], [path], [domain], [secure], [httpOnly] )

nameName of the Cookie or complete cookie specification in a dictionary.
valueValue for the cookie (eventually truned into a string).
expiresExpiration date (a TimeStamp or an ISO or RFC2822 formatted string), or maximum life in seconds (an integer).
pathCookie path validity
domainDomain for which the cookie is valid.
secureTrue to specify that the cookie can be sent only in https.
httpOnlyIf true, this cookie will be invisible to client side scripts, and will be only sent to the server.

This facility allows to store variables on the remote system (usually a web browser), which will send them back each time it connects again.

The cookies sent through this function will be received in the cookies member of subquesent call to this or other scripts.

Parameters to be left blank can be skipped using nil; however, it may be useful to use the named parameter convention.

For example:

   Reply.setCookie( "cookie1", "value1", nil, nil, ".mydomain.com", false, true )

   // but probably better
   Reply.setCookie(
      name|"cookie1",
      value|"value1",
      domain|".mydomain.com",
      httpOnly|true
      )

Only the name parameter is mandatory.

Note: Cookies must be set before output is sent to the upstream server.

setHeader()

Adds or remove a reply header.

Reply.setHeader( name, [value] )

nameThe header to be created or removed.
valueIf given and not nil, the value to be stored in the header; if not given, or nil, the header will be removed.

This sets the given header to the required value. The value parameter can be of any type; if it's not a string, a standard conversion to string will be attempted.

In case value is not given or is nil, the header is removed.

The header name is automatically capitalized at the beginning and after each '-' symbol.

Note: Pay attention to the fact that the maps in which headers are stored are case-sensitive. A case mismatch may cause an undesired duplication of the header.


Made with faldoc 2.2.1