body. Specifying a new response body

$response:body[DATA]   

Here,
DATA substitutes for the whole response body.

DATA may be a string, file or hash of parameters.

Keys of hash of parameters: [3.1.4]
file - name of file on disk (in this case Parser supports continuing of broken downloads. [3.1.4]);
name - name of file to pass to visitor;
mdate
- date and time of file last modification to pass to visitor.

If
content-type of sent file is known, Content-Type header is also output to the browser (see "Fields of object of class file").

See also
$response:download.

Example of how to replace the whole body of the response with the results of the script's work
$response:body[^file::cgi[script.cgi]]

…will replace the body of the response with the data returned by the program
script.cgi.

Example of how to create and output an image
$square[^image::create(100;100;0x000000)]
^square.
circle(50;50;10;0xFFFFFF)
$
response:body[^square.gif[]]

As a result, the browser will output a black square with a white circle. Besides, a necessary type of file (content-type) according to table
MIME-TYPES will be reported to the browser.


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 20.09.2007