Qore HttpServerUtil Module Reference
1.0.12
|
Abstract class for HTTP handlers for handling protocol switching. More...
Public Member Methods | |
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 More... | |
stop () | |
called from the HTTP server when the socket should be closed due to an external request More... | |
stop (softstring lid) | |
called from the HTTP server when the socket should be closed due to an HTTP listener being stopped More... | |
Private Member Methods | |
Mutex | m () |
listener reference hash mutex | |
abstract | 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 More... | |
stopImpl () | |
called from the HTTP server when the socket should be closed due to an external request More... | |
stopImpl (string lid) | |
called from the HTTP server when the socket should be closed because the listener is stopping More... | |
Private Attributes | |
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 | |
Abstract class for HTTP handlers for handling protocol switching.
To accept a new dedicated socket connection, make sure the return value of the handleRequest()
method returns code 101
(ie Switching Protocols
); after which this class's start() and then startImpl() methods are called.
To accept a dedicated socket connection, handleRequest()
must return a hash (ideally an HttpServer::HttpResponseInfo hash) with the following keys:
"code"
: assign to 101 (ie "Switching Protocols"
); if this is returned, then the start() method will be called with the Socket object for the new connection"hdr"
: (optional) set this key to a hash of extra header information to be returned with the response "code"
: the HTTP return code (see HttpServer::HttpCodes)"body"
: the message body to return in the response"close"
: (optional) set this key to True if the connection should be unconditionally closed when the handler returns"hdr"
: (optional) set this key to a hash of extra header information to be returned with the response HttpServer::AbstractHttpSocketHandlerInterface::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
This method should not return until the connection is closed or the stop() method is called
lid | the listener ID |
cx | call context hash; this hash will have the following keys:
|
hdr | a hash of headers in the request |
s | the Socket object for the dedicated connection |
|
privatepure virtual |
called from the HTTP server after the handleRequest() method indicates that a dedicated connection should be established
This method should not return until the connection is closed or the stop() (and therefore stopImpl()) method is called
lid | the listener ID |
cx | call context hash; this hash will have the following keys:
|
hdr | a hash of headers in the request |
s | the Socket object for the dedicated connection |
HttpServer::AbstractHttpSocketHandlerInterface::stop | ( | ) |
called from the HTTP server when the socket should be closed due to an external request
The start() method should return as soon as possible after this method is called
Child classes should implement the stopImpl() method which is called from this method to implement custom stop actions.
HttpServer::AbstractHttpSocketHandlerInterface::stop | ( | softstring | lid | ) |
called from the HTTP server when the socket should be closed due to an HTTP listener being stopped
The start() method for all connections on the particular listener should return as soon as possible after this method is called.
Child classes should implement the stopImpl(string) method which is called from this method to implement custom stop actions for particular listeners.
lid | the listener ID |
|
private |
called from the HTTP server when the socket should be closed due to an external request
The start() method should return as soon as possible after this method is called
|
private |
called from the HTTP server when the socket should be closed because the listener is stopping
The start() method for all connections handled by the given listener should return as soon as possible after this method is called
lid | the listener ID |