Qore HttpStreamClient Module Reference 1.0
Loading...
Searching...
No Matches
HttpStreamClient Namespace Reference

The HttpStreamClient namespace contains all the public definitions in the HttpStreamClient module. More...

Classes

class  HTTPResponseStream
 HTTP response stream for incremental body reading. More...
 
hashdecl  HTTPResponseStreamInfo
 Response stream information hashdecl. More...
 

Functions

HTTPResponseStream sendAndStream (soft< reference< hash< auto > > > info, timeout default_timeout, soft< hash< auto > > headers, soft< data > body, soft< string > path, HTTPClient client, string method)
 Sends an HTTP request and returns a stream for reading the response body.
 

Detailed Description

The HttpStreamClient namespace contains all the public definitions in the HttpStreamClient module.

Function Documentation

◆ sendAndStream()

HTTPResponseStream HttpStreamClient::sendAndStream ( soft< reference< hash< auto > > >  info,
timeout  default_timeout,
soft< hash< auto > >  headers,
soft< data >  body,
soft< string >  path,
HTTPClient  client,
string  method 
)

Sends an HTTP request and returns a stream for reading the response body.

Parameters
clientthe HTTPClient to use for the request
methodthe HTTP method (GET, POST, etc.)
paththe request path
bodyoptional request body
headersoptional additional headers
inforeference to receive extended response information
default_timeoutoptional default timeout for stream read operations
Returns
an HTTPResponseStream object for reading the response body

This function sends an HTTP request with getbody=False so that only the headers are received. The body can then be read incrementally using the returned stream.

Example:
HTTPClient client({"url": "https://api.example.com"});
hash<auto> info;
HTTPResponseStream stream = HttpStreamClient::sendAndStream(client, "GET", "/events",
NOTHING, {"Accept": "text/event-stream"}, \info);
# Read events...
stream.close();