Qore RestHandler Module Reference  1.5.2
RestHandler::RestStreamRequest Class Reference

the base class for handling HTTP chunked requests and responses within the RestHandler infrastructure More...

Inheritance diagram for RestHandler::RestStreamRequest:

Public Member Methods

 constructor (RestHandler::AbstractRestStreamRequestHandler n_stream, HttpServer::HttpListenerInterface listener, HttpServer::AbstractHttpRequestHandler handler, Socket s, hash< auto > cx, hash< auto > hdr, auto body)
 creates the object with the given attributes
 
 destructor ()
 destroys the object and updates the request handler about the status of the persistent connection
 

Private Member Methods

hash< HttpServer::HttpHandlerResponseInfogetResponseHeaderMessageImpl ()
 
nothing recvImpl (hash< auto > v)
 callback method for receiving chunked data; this calls RestHandler::AbstractRestStreamRequestHandler::recv() with the argument More...
 
auto sendImpl ()
 callback method for sending chunked data; this calls RestHandler::AbstractRestStreamRequestHandler::send() and returns the result More...
 

Detailed Description

the base class for handling HTTP chunked requests and responses within the RestHandler infrastructure

Member Function Documentation

◆ getResponseHeaderMessageImpl()

hash<HttpServer::HttpHandlerResponseInfo> RestHandler::RestStreamRequest::getResponseHeaderMessageImpl ( )
private
Returns
a HttpHandlerResponseInfo hash with the following keys:
  • "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
Note
this method is called after the message body has been received

◆ recvImpl()

nothing RestHandler::RestStreamRequest::recvImpl ( hash< auto >  v)
private

callback method for receiving chunked data; this calls RestHandler::AbstractRestStreamRequestHandler::recv() with the argument

Parameters
vthe 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:
  • "data": the string or binary data, or, in the case of a non-chunked request, the already decoded and deserialized request body, in which case the "deserialized" key will be True
  • "chunked": True if the data was received with chunked transfer encoding, False if not
  • "deserialized": present and set to True if a non-chunked request was received, and the body has already been deserialized
Header or trailer data is placed in a hash with the following keys:
  • "hdr": this can be assigned to NOTHING for the trailer hash if the data was not sent chunked or no trailers were included in a chunked message
  • "obj": this is the owning object (so socket parameters can be changed based on headers received, such as, for example, socket character encoding)

◆ sendImpl()

auto RestHandler::RestStreamRequest::sendImpl ( )
private

callback method for sending chunked data; this calls RestHandler::AbstractRestStreamRequestHandler::send() and returns the result

Returns
The chunked HTTP data to send; this method must return either a string or a binary value each time it is called to give the chunked data to send; when all data has been sent, then a hash of message trailers can be returned or simply NOTHING which will close the chunked message