30 unsigned int connect_timeout ,
unsigned int response_timeout ) :
31 GNet::
Client(resolver_info,connect_timeout,response_timeout,0U,eol) ,
38 << connect_timeout <<
" " << response_timeout ) ;
47 G_DEBUG(
"GSmtp::RequestClient::onConnect" ) ;
49 send( requestLine(m_request) ) ;
54 G_DEBUG(
"GSmtp::RequestClient::request: \"" << payload <<
"\"" ) ;
55 if( busy() )
throw ProtocolError() ;
57 m_timer.startTimer( 0U ) ;
61 void GSmtp::RequestClient::onTimeout()
64 send( requestLine(m_request) ) ;
69 return !m_request.empty() ;
82 G_WARNING(
"GSmtp::RequestClient::onDeleteImp: error: " << reason ) ;
87 eventSignal().emit( m_key , reason.empty() ? std::string(
"error") : reason ) ;
89 Base::onDeleteImp( reason , b ) ;
102 std::string scan_result = result(line) ;
104 eventSignal().emit( m_key , scan_result ) ;
115 std::string GSmtp::RequestClient::requestLine(
const std::string & payload )
const
117 return payload + m_eol ;
120 std::string GSmtp::RequestClient::result( std::string line )
const
123 return !m_ok.empty() && line.find(m_ok) == 0U ? std::string() : line ;
static std::string printable(const std::string &in, char escape= '\\')
Returns a printable represention of the given input string.
RequestClient(const std::string &key, const std::string &ok, const std::string &eol, const GNet::ResolverInfo &host_and_service, unsigned int connect_timeout, unsigned int response_timeout)
Constructor.
virtual void onDeleteImp(const std::string &, bool)
Final override from GNet::Client.
A class that holds a host/service name pair and optionally the results of a name-to-address lookup...
virtual void onConnect()
Final override from GNet::SimpleClient.
static void trim(std::string &s, const std::string &ws)
Trims both ends of s, taking off any of the 'ws' characters.
virtual ~RequestClient()
Destructor.
virtual void onDelete(const std::string &, bool)
Final override from GNet::HeapClient.
virtual void onSendComplete()
Final override from GNet::BufferedClient.
virtual void onSecure(const std::string &)
Final override from GNet::SocketProtocolSink.
A class which acts as an SMTP client, extracting messages from a message store and forwarding them to...
virtual bool onReceive(const std::string &)
Final override from GNet::Client.
void request(const std::string &)
Issues a request.
bool busy() const
Returns true after request() and before the subsequent event signal.
std::string displayString(bool simple=false) const
Returns a string representation for logging and debug.
A client class that interacts with a remote process with a stateless line-based request/response prot...