|
|
Responses
Many API methods have a common set of responses, that are:
- zero
-
means that the module could not handle the request.
- minus one
-
means that the requested object was a directory. The request will be
sent to a directory module, if present.
- Stdio.File
-
the file object will be sent to the browser, after the Content
types module has determined the appropriate content type.
- response mapping
-
contains all information necessary for Challenger to send the result
to the browser. It includes header information as well as file
content. The response mapping should not be created by hand but rather
by an appropriate response method.
The response methods are available if roxenlib has been
inherited. They are:
- http_string_answer( string contents, void|string type )
-
simply returns the contents as the content type type, or
by default text/html.
- http_rxml_answer( string rxml, object id,
void|object(Stdio.File) file, string|void type )
-
returns rxml after sending it through the RXML parser, as
text/html unless the type argument is given.
- http_file_answer( Stdio.File file, void|string type, void|string
len)
-
returns the contents of file which should be open for reading.
- http_auth_required( string realm, string message )
-
is used to prompt the user to log on. A web browser will open
a dialog prompting the user to fill in her user name and password. The
realm argument is a string which will be used to distinguish
different protected domains on the same server from each other. The
message argument will be shown if the user decides not to try
to log on.
- http_redirect( string url, void|object id )
-
creates a redirect response that will make the web browser try to
fetch the redirected page. id is only required if the URL is a
relative URL, that is, one that doesn't specify a protocol and server,
in which case the http_redirect() will need more data
to create a complete URL.
- http_pipe_in_progress()
-
tells Challenger that your module will take charge of delivering data
to the user. Challenger will ignore the request from now on
and let the module handle the file object associated with the
request. The file object is found in the my_fd field of the
id object.
|
|