Qore HttpServerUtil Module Reference 1.3
Loading...
Searching...
No Matches
HttpServer::AbstractHttpSocketHandler Class Reference

abstract class that all HTTP dedicated socket handler objects must inherit from More...

Inheritance diagram for HttpServer::AbstractHttpSocketHandler:
[legend]

Public Member Functions

 constructor (*AbstractAuthenticator auth)
 create the object optionally with the given AbstractAuthenticator
Public Member Functions inherited from HttpServer::AbstractHttpRequestHandler
*hash< HttpResponseInfoauthenticateRequest (HttpListenerInterface listener, hash< auto > hdr, reference< hash< auto > > cx)
 Authenticates the request if possible.
 constructor (*AbstractAuthenticator n_auth, softbool n_stream=False)
 create the object optionally with the given AbstractAuthenticator
*data getMessageBody (Socket s, hash< auto > hdr, *data body, bool decode=True)
 optionally retrieves and post-processes any message body
hash< HttpResponseInfohandleExpectHeader (hash< auto > cx, hash< auto > hdr)
 Called if the request contains an "Expect: 100-continue" header.
hash< HttpResponseInfohandleRequest (hash< auto > cx, hash< auto > hdr, *data body)
 will be called when a request is received that should be directed to the handler
hash< HttpResponseInfohandleRequest (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
 notifyClosed (*code c)
 calls the argument when the persistent connection is closed
nothing persistentClosed ()
 called externally when a persistent connection is closed
*hash< HttpResponseInfopreprocessRequest (HttpListenerInterface listener, reference< hash< auto > > hdr, reference< hash< auto > > cx)
 Preproecsses a request before authentication.
 restoreThreadLocalData (*hash< auto > data)
 called after handleRequest() with any data returned from saveThreadData()
*hash< auto > saveThreadLocalData ()
 called before handleRequest()
 setPersistent (bool p=True)
 called externally to notify the handler that the connection will be persistent
Public Member Functions inherited from HttpServer::AbstractHttpSocketHandlerInterface
code setExternallyManaged (softstring lid, hash< auto > cx, Socket s)
 Returns a closure that can be used to confirm that the connection has been closed.
bool start (softstring lid, hash< auto > cx, hash< auto > hdr, Socket s)
 called from the HTTP server after the handleRequest() method indicates that a dedicated connection should be established
 stop ()
 called from the HTTP server when the socket should be closed due to an external request
 stop (softstring lid)
 called from the HTTP server when the socket should be closed due to an HTTP listener being stopped

Additional Inherited Members

Static Public Member Functions 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
static hash< HttpResponseInfomake200 (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< HttpResponseInfomake200 (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< HttpResponseInfomake200 (InputStream chunked_body)
 creates a hash for an HTTP 200 OK error response with the response message body from an input stream
static hash< HttpResponseInfomake200 (string fmt,...)
 creates a hash for an HTTP 200 OK error response with the response message body as a string
static hash< HttpResponseInfomake400 (hash< auto > hdr, string fmt,...)
 creates a hash for an HTTP 400 error response with the response message body as a string
static hash< HttpResponseInfomake400 (string fmt,...)
 creates a hash for an HTTP 400 error response with the response message body as a string
static hash< HttpResponseInfomake500 (hash< auto > hdr, string fmt,...)
 creates a hash for an HTTP 500 error response with the response message body as a string
static hash< HttpResponseInfomake500 (string fmt,...)
 creates a hash for an HTTP 500 error response with the response message body as a string
static hash< HttpResponseInfomake501 (hash< auto > hdr, string fmt,...)
 creates a hash for an HTTP 501 error response with the response message body as a string
static hash< HttpResponseInfomake501 (string fmt,...)
 creates a hash for an HTTP 501 error response with the response message body as a string
static hash< HttpResponseInfomakeResponse (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< HttpResponseInfomakeResponse (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< HttpResponseInfomakeResponse (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< HttpResponseInfomakeResponse (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
static hash< HttpResponseInfomakeResponse (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< HttpResponseInfomakeResponse (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< HttpResponseInforedirect (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
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
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
Protected Member Functions 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
AbstractStreamRequest getStreamRequestImpl (HttpListenerInterface listener, Socket s, hash< auto > cx, hash< auto > hdr, *data body)
 returns the AbstractStreamRequest object for handling chunked requests
Protected Member Functions inherited from HttpServer::AbstractHttpSocketHandlerInterface
 handlerStopped (softstring lid)
 Called when the handler stops.
Mutex m ()
 listener reference hash mutex
abstract bool startImpl (softstring lid, hash< auto > cx, hash< auto > hdr, Socket s)
 called from the HTTP server after the handleRequest() method indicates that a dedicated connection should be established
 stopImpl ()
 called from the HTTP server when the socket should be closed due to an external request
 stopImpl (string lid)
 called from the HTTP server when the socket should be closed because the listener is stopping
Protected Attributes inherited from HttpServer::AbstractHttpSocketHandlerInterface
hash< string, int > lh
 hash of listener references; this is to stop all connections associated with a particular listener
hash< string, bool > lsh
 hash of listener stop flags
bool stop = False
 stop listener flag

Detailed Description

abstract class that all HTTP dedicated socket handler objects must inherit from

reimplement at least handleRequest() and startImpl() in subclasses

Member Function Documentation

◆ constructor()

HttpServer::AbstractHttpSocketHandler::constructor ( *AbstractAuthenticator auth)

create the object optionally with the given AbstractAuthenticator

Parameters
auththe authentication object to use to authenticate connections (see AbstractAuthenticator); if no AbstractAuthenticator object is passed, then by default no authentication will be required