Qore HttpServerUtil Module Reference 1.1
|
abstract class for HTTP request handlers anchored at a specific URL More...
#include <HttpServerUtil.qm.dox.h>
Public Member Methods | |
constructor (string n_url_root, *AbstractAuthenticator auth) | |
creates the object based on the URL root and optional authenticator More... | |
string | getRelativePath (string path) |
returns the relative path anchored from the url_root if possible More... | |
Public Member Methods inherited from HttpServer::AbstractHttpRequestHandler | |
constructor (*AbstractAuthenticator n_auth, softbool n_stream=False) | |
create the object optionally with the given AbstractAuthenticator More... | |
*data | getMessageBody (Socket s, hash< auto > hdr, *data body, bool decode=True) |
optionally retrieves and post-processes any message body | |
private AbstractStreamRequest | getStreamRequestImpl (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body) |
returns the AbstractStreamRequest object for handling chunked requests | |
hash< HttpResponseInfo > | handleExpectHeader (hash< auto > cx, hash< auto > hdr) |
Called if the request contains an "Expect: 100-continue" header. More... | |
hash< HttpResponseInfo > | handleRequest (hash< auto > cx, hash< auto > hdr, *data body) |
will be called when a request is received that should be directed to the handler More... | |
hash< HttpResponseInfo > | handleRequest (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body) |
top-level request handling method | |
bool | isPersistent () |
returns True if the current connection is persistent, False if not | |
string | maskData (string msg) |
this method can be used to mask data in debug messages More... | |
notifyClosed (*code c) | |
calls the argument when the persistent connection is closed | |
nothing | persistentClosed () |
called externally when a persistent connection is closed | |
restoreThreadLocalData (*hash< auto > data) | |
called after handleRequest() with any data returned from saveThreadData() More... | |
*hash< auto > | saveThreadLocalData () |
called before handleRequest() More... | |
setPersistent (bool p=True) | |
called externally to notify the handler that the connection will be persistent | |
Public Attributes | |
string | url_root |
root part of URL for matching requests | |
Public Attributes inherited from HttpServer::AbstractHttpRequestHandler | |
*AbstractAuthenticator | auth |
the optional AbstractAuthenticator for requests to this handler | |
bool | decompress = True |
if POSTed data should be decompressed automatically if there is content-encoding | |
bool | decompress_to_string = True |
if automatically decompressed POSTed data should be converted to a string More... | |
const | NotificationThreadKey = "_AHRH_pc" |
thread-local key string for notification callbacks | |
const | PersistenceThreadKey = "_AHRH_p" |
thread-local key string for the persistent flag | |
bool | stream |
if the handler supports streaming requests/responses with chunked data | |
timeout | timeout_ms = HttpServer::DefaultTimeout |
send and receive socket timeout in milliseconds | |
Additional Inherited Members | |
Static Public Member Methods inherited from HttpServer::AbstractHttpRequestHandler | |
static data | decodeBody (string content_encoding, binary body, *string string_encoding) |
decodes a message body with content-encoding | |
static binary | encodeBody (string content_encoding, data body) |
encodes a message body with content-encoding | |
static *string | getLogMessage (hash< auto > cx, hash api, reference params, *reference< string > args) |
helper method for handling log messages More... | |
static hash< HttpResponseInfo > | make200 (hash< auto > hdr, InputStream chunked_body) |
creates a hash for an HTTP 200 OK error response with the response message body from an input stream | |
static hash< HttpResponseInfo > | make200 (hash< auto > hdr, string fmt) |
creates a hash for an HTTP 200 OK error response with the response message body as a string | |
static hash< HttpResponseInfo > | make200 (InputStream chunked_body) |
creates a hash for an HTTP 200 OK error response with the response message body from an input stream | |
static hash< HttpResponseInfo > | make200 (string fmt) |
creates a hash for an HTTP 200 OK error response with the response message body as a string | |
static hash< HttpResponseInfo > | make400 (hash< auto > hdr, string fmt) |
creates a hash for an HTTP 400 error response with the response message body as a string | |
static hash< HttpResponseInfo > | make400 (string fmt) |
creates a hash for an HTTP 400 error response with the response message body as a string | |
static hash< HttpResponseInfo > | make500 (hash< auto > hdr, string fmt) |
creates a hash for an HTTP 500 error response with the response message body as a string | |
static hash< HttpResponseInfo > | make500 (string fmt) |
creates a hash for an HTTP 500 error response with the response message body as a string | |
static hash< HttpResponseInfo > | make501 (hash< auto > hdr, string fmt) |
creates a hash for an HTTP 501 error response with the response message body as a string | |
static hash< HttpResponseInfo > | make501 (string fmt) |
creates a hash for an HTTP 501 error response with the response message body as a string | |
static hash< HttpResponseInfo > | makeResponse (hash< auto > hdr, int code, binary body) |
creates a hash for an HTTP response with the response code and the response message body as binary data | |
static hash< HttpResponseInfo > | makeResponse (hash< auto > hdr, int code, string fmt) |
creates a hash for an HTTP response with the response code and the response message body as a formatted string | |
static hash< HttpResponseInfo > | makeResponse (int code, *data body, *hash< auto > hdr) |
creates a hash for an HTTP response with the response code and a literal response message body | |
static hash< HttpResponseInfo > | makeResponse (int code, *InputStream chunked_body, *hash< auto > hdr) |
creates a hash for an HTTP response with the response code and a response message body from an input stream More... | |
static hash< HttpResponseInfo > | makeResponse (int code, binary body) |
creates a hash for an HTTP response with the response code and the response message body as binary data | |
static hash< HttpResponseInfo > | makeResponse (int code, string fmt) |
creates a hash for an HTTP response with the response code and the response message body as a formatted string | |
static hash< HttpResponseInfo > | redirect (hash< auto > cx, hash< auto > request_hdr, string path, int status_code=301, *hash< auto > response_hdr) |
generates a redirect hash for the given path | |
static | staticNotificationCleanup () |
removes the thread-local data key in case the object is destroyed in another thread | |
static | staticPersistenceCleanup () |
removes the thread-local data key in case the object is destroyed in another thread | |
Private Member Methods inherited from HttpServer::AbstractHttpRequestHandler | |
nothing | checkPersistent (hash< auto > cx, hash< auto > hdr) |
this method will throw an exception if a persistent connection cannot be granted | |
abstract class for HTTP request handlers anchored at a specific URL
HttpServer::AbstractUrlHandler::constructor | ( | string | n_url_root, |
*AbstractAuthenticator | auth | ||
) |
creates the object based on the URL root and optional authenticator
n_url_root | the root part of the URL path without the leading "/" |
auth | the authentication object to use to authenticate connections (see AbstractAuthenticator); if no AbstractAuthenticator object is passed, then by default no authentication will be required |
string HttpServer::AbstractUrlHandler::getRelativePath | ( | string | path | ) |
returns the relative path anchored from the url_root if possible
URI query arguments are stripped off, if the url_root cannot be matched then the path is returned with URI query arguments removed