roar
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Roar::Session::ReadIntermediate< BodyT > Class Template Reference

Utility class to build up read operations. More...

#include <session.hpp>

Collaboration diagram for Roar::Session::ReadIntermediate< BodyT >:

Public Member Functions

 ReadIntermediate (ReadIntermediate &&)=default
 
ReadIntermediateoperator= (ReadIntermediate &&)=default
 
ReadIntermediatebodyLimit (std::size_t limit)
 Set a body limit.
 
ReadIntermediatebodyLimit (boost::beast::string_view limit)
 Set a body limit.
 
ReadIntermediatenoBodyLimit ()
 Accept a body of any length.
 
ReadIntermediateonReadSome (std::function< bool(boost::beast::flat_buffer &, std::size_t)> onChunkFunc)
 Set a callback function that is called whenever some data was read.
 
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< Detail::PromiseReferenceWrap< Session >, Detail::PromiseReferenceWrap< Request< BodyT > const > >, Detail::PromiseTypeBindFail< Error const & > > commit ()
 Start reading here. If you dont call this function, nothing is read.
 
ReadIntermediateuseFixedTimeout (std::chrono::milliseconds timeout)
 Set a timeout for the whole read operation.
 

Private Member Functions

template<typename OriginalBodyT , typename... Forwards>
 ReadIntermediate (Session &session, Request< OriginalBodyT > req, Forwards &&... forwardArgs)
 
void readChunk ()
 Reads some bytes off of the stream.
 

Private Attributes

friend Session
 
std::shared_ptr< Sessionsession_
 
boost::beast::http::request_parser< BodyT > req_
 
Detail::RequestExtensions originalExtensions_
 
std::function< bool(boost::beast::flat_buffer &, std::size_t)> onChunk_
 
std::unique_ptr< promise::Promise > promise_
 
std::optional< std::chrono::milliseconds > overallTimeout_
 

Detailed Description

template<typename BodyT>
class Roar::Session::ReadIntermediate< BodyT >

Utility class to build up read operations.

Template Parameters
BodyTThe body type of this read.

Constructor & Destructor Documentation

◆ ReadIntermediate() [1/2]

template<typename BodyT >
template<typename OriginalBodyT , typename... Forwards>
Roar::Session::ReadIntermediate< BodyT >::ReadIntermediate ( Session session,
Request< OriginalBodyT >  req,
Forwards &&...  forwardArgs 
)
inlineprivate

◆ ReadIntermediate() [2/2]

template<typename BodyT >
Roar::Session::ReadIntermediate< BodyT >::ReadIntermediate ( ReadIntermediate< BodyT > &&  )
default

Member Function Documentation

◆ bodyLimit() [1/2]

template<typename BodyT >
ReadIntermediate & Roar::Session::ReadIntermediate< BodyT >::bodyLimit ( boost::beast::string_view  limit)
inline

Set a body limit.

Parameters
Thelimit as a string. Must be a number.
Returns
ReadIntermediate& Returns itself for chaining.

◆ bodyLimit() [2/2]

template<typename BodyT >
ReadIntermediate & Roar::Session::ReadIntermediate< BodyT >::bodyLimit ( std::size_t  limit)
inline

Set a body limit.

Parameters
Thelimit as an std::size_t
Returns
ReadIntermediate& Returns itself for chaining.

◆ commit()

Start reading here. If you dont call this function, nothing is read.

Returns
Promise that can be used to await the read. Promise is called with <Session& session, Request<BodyT> req>.

◆ noBodyLimit()

template<typename BodyT >
ReadIntermediate & Roar::Session::ReadIntermediate< BodyT >::noBodyLimit ( )
inline

Accept a body of any length.

Returns
ReadIntermediate& Returns itself for chaining.

◆ onReadSome()

template<typename BodyT >
ReadIntermediate & Roar::Session::ReadIntermediate< BodyT >::onReadSome ( std::function< bool(boost::beast::flat_buffer &, std::size_t)>  onChunkFunc)
inline

Set a callback function that is called whenever some data was read.

Parameters
onChunkFuncThe function to be called. Is called with the buffer and amount of bytes transferred. Return false in this function to stop reading.
Returns
ReadIntermediate& Returns itself for chaining.

◆ operator=()

template<typename BodyT >
ReadIntermediate & Roar::Session::ReadIntermediate< BodyT >::operator= ( ReadIntermediate< BodyT > &&  )
default

◆ readChunk()

template<typename BodyT >
void Roar::Session::ReadIntermediate< BodyT >::readChunk ( )
inlineprivate

Reads some bytes off of the stream.

◆ useFixedTimeout()

template<typename BodyT >
ReadIntermediate & Roar::Session::ReadIntermediate< BodyT >::useFixedTimeout ( std::chrono::milliseconds  timeout)
inline

Set a timeout for the whole read operation.

Parameters
timeoutThe timeout as a std::chrono::duration.
Returns
ReadIntermediate& Returns itself for chaining.

Member Data Documentation

◆ onChunk_

template<typename BodyT >
std::function<bool(boost::beast::flat_buffer&, std::size_t)> Roar::Session::ReadIntermediate< BodyT >::onChunk_
private

◆ originalExtensions_

template<typename BodyT >
Detail::RequestExtensions Roar::Session::ReadIntermediate< BodyT >::originalExtensions_
private

◆ overallTimeout_

template<typename BodyT >
std::optional<std::chrono::milliseconds> Roar::Session::ReadIntermediate< BodyT >::overallTimeout_
private

◆ promise_

template<typename BodyT >
std::unique_ptr<promise::Promise> Roar::Session::ReadIntermediate< BodyT >::promise_
private

◆ req_

template<typename BodyT >
boost::beast::http::request_parser<BodyT> Roar::Session::ReadIntermediate< BodyT >::req_
private

◆ Session

template<typename BodyT >
friend Roar::Session::ReadIntermediate< BodyT >::Session
private

◆ session_

template<typename BodyT >
std::shared_ptr<Session> Roar::Session::ReadIntermediate< BodyT >::session_
private

The documentation for this class was generated from the following file: