docs.roxen.comView this page in a printer friendly mode
DocsRoxenWebServer 6.1System Developer Manual PikeRoxen-specific Pike Modules
Copyright  2018, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com



Roxen

Roxen

These methods are all accessable from everywhere within Roxen via Roxen.methodname(args). (Although technically, they do not really all belong to Roxen.pmod.)

Response Methods

Convenience functions to use in Roxen modules. When you just want to return a string of data, with an optional type, this is the easiest way to do it if you do not want to worry about the internal roxen structures.

mapping http_string_answer(string text, string|void type)

Generates a response mapping with the given text as the request body with a content type of type (or "text/html" if none was given).

mapping http_file_answer(Stdio.File text, string|void type, int|void len)

Generates a response mapping with request body contents drawn from the given file object with a content type of type (or "text/html" if none was given). If no length is supplied, it is calculated for you automatically.

mapping http_rxml_answer(string rxml, RequestID id, void|Stdio.File file, void|string type)

Parse the supplied rxml and generate a response mapping with a content type of type (or "text/html" if none was given).

mapping http_low_answer(int errno, string data)

Return a response mapping with the error and data specified. The error is infact the status response, so '200' means "HTTP Document follows", and 500 means "Internal Server error", etc.

mapping http_pipe_in_progress()

mapping http_try_again(float delay)

Causes the request to be retried in delay seconds.

mapping http_redirect(string url, RequestID|void id)

Simply returns a http-redirect message to the specified URL. If the url parameter is just a virtual (possibly relative) path, the current id object must be supplied to resolve the destination URL.

mapping http_stream(Stdio.File from)

Returns a response mapping where the data returned to the client will be streamed raw from the given Stdio.File object, instead of being packaged by roxen. In other words, it's entirely up to you to make sure what you send is HTTP data.

mapping http_auth_required(string realm, string|void message)

Generates a response mapping that will instruct the web browser that the user needs to authorize himself before being allowed access. realm is the name of the realm on the server, which will typically end up in the browser's prompt for a name and password (e g "Enter username for realm at hostname:"). The optional message is the message body that the client typically shows the user, should he decide not to authenticate himself, but rather refraim from trying to authenticate himself.

In HTTP terms, this sends a 401 Auth Required response with the header WWW-Authenticate: basic realm="realm". For more info, see RFC 2617.

mapping http_proxy_auth_required(string realm, void|string message)

Generates a response mapping that will instruct the client end that it needs to authenticate itself before being allowed access. realm is the name of the realm on the server, which will typically end up in the browser's prompt for a name and password (e g "Enter username for realm at hostname:"). The optional message is the message body that the client typically shows the user, should he decide not to authenticate himself, but rather refraim from trying to authenticate himself.

In HTTP terms, this sends a 407 Proxy authentication failed response with the header Proxy-Authenticate: basic realm="realm". For more info, see RFC 2617.

Utility Functions

void set_cookie(RequestID id, string name, string value, int|void expire_time_delta, string|void domain, string|void path)

Set the cookie specified by 'name' to 'value'. Sends a Set-Cookie header.

The expire_time_delta, domain and path arguments are optional.

If the expire_time_delta variable is -1, the cookie is set to

expire five years in the future. If it is 0 or ommited, no expire information is sent to the client. This usualy results in the cookie being kept until the browser is exited.

string http_date(int t)

Returns a http_date, as specified by the HTTP-protocol standard. This is used for logging as well as the Last-Modified and Time heads in the reply.

string http_encode_string(string f)

Encode a string for inclusion in HTTP headers.

string http_encode_cookie(string f)

Encode a string for inclusion in a cookie.

string http_encode_url(string f)

Encode a string for inclusion in a URL.

void remove_cookie(RequestID id, string name, string value, string|void domain, string|void path)

Remove the cookie specified by 'name'. Sends a Set-Cookie header with an expire time of 00:00 1/1 1970. The domain and path arguments are optional.