|
Qore HttpServer Module Reference
0.3.8
|
abstract class for streaming HTTP chunked requests/responses More...
Public Member Functions | |
| constructor (HttpListener listener, AbstractHttpRequestHandler handler, Socket s, hash cx, hash hdr, any body) | |
| creates the object with the given attributes | |
| private hash | getResponseHeaderMessage () |
| this method returns the response message description hash by calling getResponseHeaderMessageImpl() More... | |
| private hash | getResponseHeaderMessageImpl () |
| this method should return the response message description hash More... | |
| private nothing | recv (hash v) |
| this is the primary callback for receiving chunked data; data will be logged, and then recvImpl() is called More... | |
| private nothing | recvImpl (hash v) |
| abstract callback method for receiving chunked data More... | |
| private any | send () |
| this is the primary callback for sending chunked responses; first sendImpl() is called to get the raw data, and then any chunked data is encoded by this method if required | |
| private any | sendImpl () |
| abstract callback method for sending chunked data More... | |
| private hash | sendResponse () |
| called to either create the response hash or send a chunked response directly More... | |
Private Attributes | |
| any | body |
| any message body given in a non-chunked request; could already be deserialized | |
| hash | cx |
| the call context variable | |
| AbstractHttpRequestHandler | handler |
| the request handler for the request | |
| hash | hdr |
| a hash of request headers | |
| HttpListener | listener |
| the listener servicing the request for logging purposes | |
| Socket | s |
| the Socket object for the response | |
abstract class for streaming HTTP chunked requests/responses
This class is the base class for handling HTTP stream requests; i.e. with chunked data
The calling order is as follows:
| private hash HttpServer::AbstractStreamRequest::getResponseHeaderMessage | ( | ) |
this method returns the response message description hash by calling getResponseHeaderMessageImpl()
"code": the HTTP return code (see HttpServer::HttpCodes)"body": the message body to return in the response; if this key is returned, then the reply is sent immediately; a chunked reply is not made, and send() and sendImpl() are not called"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| private hash HttpServer::AbstractStreamRequest::getResponseHeaderMessageImpl | ( | ) |
this method should return the response message description hash
The default implementation in this class is to return a 501 Not Implemented response; override in subclasses to return a custom response. Omit the "body" key to ensure that a chunked response is sent and the send() and sendImpl() callbacks are called.
"code": the HTTP return code (see HttpServer::HttpCodes)"body": the message body to return in the response; if this key is returned, then the reply is sent immediately; a chunked reply is not made, and send() and sendImpl() are not called"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| private nothing HttpServer::AbstractStreamRequest::recv | ( | hash | v | ) |
this is the primary callback for receiving chunked data; data will be logged, and then recvImpl() is called
content decoding is not possible with chunked data because only the entire message can be decoded
| private nothing HttpServer::AbstractStreamRequest::recvImpl | ( | hash | v | ) |
abstract callback method for receiving chunked data
| v | the first time this method is called with a hash of the message headers in the "hdr" key, and then with any message body in the "data"; if a chunked HTTP message is received, then this method is called once for each chunk; when the message has been received, then this method is called with a hash representing any trailer data received in a chunked transfer or NOTHING if the data was received in a normal message body or if there was no trailer data in a chunked transfer. The argument to this callback is always a hash; data calls have the following keys:
|
| private any HttpServer::AbstractStreamRequest::sendImpl | ( | ) |
abstract callback method for sending chunked data
| private hash HttpServer::AbstractStreamRequest::sendResponse | ( | ) |
called to either create the response hash or send a chunked response directly
This method calls getResponseHeaderMessageImpl() to get the response code, headers and optionally a response message body. If a "Content-Encoding: chunked" header is included, then the response is sent chunked using the send() callback; in this case the "reply_sent" key in the response is set to True. Otherwise, any message body is immediately encoded (if accepted by the requestor).