HttpClient Class Reference

#include <Pt/XmlRpc/HttpClient.h>

A client for remote procedure calls via HTTP.

Inherits Client, and Connectable.

Public Member Functions

 HttpClient ()
 Constructor.
 
 HttpClient (const Net::Endpoint &ep, const std::string &url)
 Construct with host and service URL.
 
 HttpClient (System::EventLoop &loop)
 Construct with EventLoop used for I/O.
 
 HttpClient (System::EventLoop &loop, const Net::Endpoint &ep, const std::string &url)
 Construct with host and service URL.
 
virtual ~HttpClient ()
 Destructor.
 
const RemoteCall * activeProcedure () const
 The currently executing procedure.
 
void cancel ()
 Cancels the currently executing procedure.
 
void close ()
 Closes the connection.
 
const Net::Endpointhost () const
 Returns target host.
 
System::EventLooploop () const
 Gets the used EventLoop.
 
void setActive (System::EventLoop &loop)
 Sets the EventLoop to use for I/O.
 
void setHost (const Net::Endpoint &ep)
 Sets host to connect.
 
void setHost (const Net::Endpoint &ep, const Net::TcpSocketOptions &opts)
 Sets host to connect.
 
void setKeepAlive ()
 Enables HTTP keep-alive.
 
void setPeerName (const std::string &peer)
 Set expected SSL peer name.
 
void setSecure (Ssl::Context &ctx)
 Sets SSL context.
 
void setServiceUrl (const std::string &url)
 Sets the service URL.
 
void setServiceUrl (const char *url)
 Sets the service URL.
 
void setTarget (const Net::Endpoint &ep, const std::string &url)
 Sets target host and service URL.
 
void setTarget (const Net::Endpoint &ep, const Net::TcpSocketOptions &opts, const std::string &url)
 Sets target host and service URL.
 
void setTimeout (std::size_t timeout)
 Sets timeout for I/O operations.
 

Protected Member Functions

bool advanceMessage ()
 Formats the XML-RPC message. More...
 
void beginMessage (std::ostream &os)
 Formats the XML-RPC message. More...
 
void beginResult (std::istream &is)
 Parses the XML-RPC result. More...
 
void finishMessage ()
 Formats the XML-RPC message. More...
 
virtual bool isFailed () const
 Indicates if the procedure has failed.
 
virtual void onBeginInvoke ()
 An asynchronous remote procedure is invoked. More...
 
virtual void onCancel ()
 Cancels the remote procedure call. More...
 
virtual void onInvoke ()
 A synchronous remote procedure is called. More...
 
bool parseResult ()
 Parses the XML-RPC result. More...
 
void processResult (std::istream &is)
 Parses the XML-RPC result. More...
 
void setFault (int rc, const char *msg)
 Fails the current procedure. More...
 
void setReady ()
 Parses the XML-RPC result. More...
 

Member Function Documentation

virtual void onBeginInvoke ( )
protectedvirtual

Derived Clients implement this method to format and send a message to the service.

Implements Client.

virtual void onInvoke ( )
protectedvirtual

Derived Clients implement this method to format and send a message to the service and receive and parse the result.

Implements Client.

virtual void onCancel ( )
protectedvirtual

Derived Clients implement this method to cancel the remote procedure call.

Reimplemented from Client.

void beginMessage ( std::ostream &  os)
protectedinherited

This method is used by derived Clients in onInvoke() and onCall() to begin formatting a XML-RPC message to a std::ostream.

bool advanceMessage ( )
protectedinherited

This method is used by derived Clients in onInvoke() and onCall() to format a XML-RPC message. Each call generates a chunk of the message and returns true if the message is complete.

void finishMessage ( )
protectedinherited

This method is used by derived Clients in onInvoke() and onCall() to format the end of a XML-RPC message. It is called after advanceMessage() returns true.

void beginResult ( std::istream &  is)
protectedinherited

This method is used by derived Clients to begin parsing a XML-RPC result from a std::istream.

bool parseResult ( )
protectedinherited

This method is used by derived Clients to parse a XML-RPC result Each call consumes the available data from the std::istream set with beginResult() and returns true if the result is complete.

void processResult ( std::istream &  is)
protectedinherited

This method is used by derived Clients after the XML-RPC result has been parsed by parseResult(). The current RemoteProcedure will receive completion notification to process the result.Parses the XML-RPC result.

This method is used by derived Clients in in onCall() to parse a XML-RPC result from a std::istream.

void setFault ( int  rc,
const char *  msg 
)
protectedinherited

This method is used by derived Clients before calling finishResult() so that the RemoteProcedure throws a Fault when the result is processed.

void setReady ( )
protectedinherited

This method is used by derived Clients after the XML-RPC result has been parsed by parseResult(). The current RemoteProcedure will receive completion notification to process the result.