Index | | | Related pages | | | Classes | | | Objects | | | Functions | | | Entities | | | Function Sets |
objects Reply
Reflects the reply that this script has sent (or will send). more...
Properties | |
fields | HTTP reply fields. |
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 | |
commit | Sends immediately the header and pending data. |
setCookie | sets a cookie that will be received next time that a script is called. |
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.
Note: Actually, the contents of this object are read by the integration module by property name protocol. In other words, it is not strictly necessary to change this object's properties to have them reflected in the output reply. In other words, this object may be substituted by another instance of any class, having the same fields or part of them.
Note: Content-type and Content-encoding
fields |
HTTP reply fields.
Mangling this fields allow scripts to alter the type of data that the server will send to the clients. In example, it is possible to transform the output the string in an image by setting the field "Content-type" to "image/jpeg". Please, refer to HTTP RFC 2616 at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for further details. |
reason |
Descriptive http reply reason.
In the "+200 OK" standard reply, it's the "OK" part. |
sent |
True when the header has been delivered, false if the header is still unsent. |
status |
Numeric HTTP reply code.
In example, 200 (meaning OK). |
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.
sets a cookie that will be received next time that a script is called.
Reply.setCookie( name, [value], [expires], [path], [domain], [secure], [httpOnly] ) | |
name | Name of the Cookie or complete cookie specification in a dictionary. |
value | Value for the cookie (eventually truned into a string). |
expires | Expiration date (a TimeStamp or an ISO or RFC2822 formatted string) |
path | Cookie path validity |
domain | Domain for which the cookie is valid. |
secure | True to specify that the cookie can be sent only in https. |
httpOnly | If 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 convencion, that is, passing a single dictionary containing the parameter names and their values.
In 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.
Index | | | Related pages | | | Classes | | | Objects | | | Functions | | | Entities | | | Function Sets |