#include <Pt/Http/Client.h>
An HTTP client. More...
Inherits Connectable, and NonCopyable.
Public Member Functions | |
Client () | |
Default Constructor. | |
Client (const Net::Endpoint &ep) | |
Construct with host to connect to. | |
Client (System::EventLoop &loop) | |
Construct with event loop. | |
Client (System::EventLoop &loop, const Net::Endpoint &ep) | |
Construct with loop and host to connect to. | |
~Client () | |
Destructor. | |
void | beginReceive () |
Begin receiving the reply. | |
void | beginSend (bool finished=true) |
Begin sending the request. | |
void | close () |
Closes the connection and cancels all operations. | |
MessageProgress | endReceive () |
End receiving the reply. | |
MessageProgress | endSend () |
End sending the request. | |
const Net::Endpoint & | host () const |
Returns the host to connect to. | |
System::EventLoop * | loop () const |
Returns the used event loop. | |
std::istream & | receive () |
Blocks until reply is received. | |
Reply & | reply () |
Returns the received reply. | |
const Reply & | reply () const |
Returns the received reply. | |
Signal< Client & > & | replyReceived () |
Signals that a part of the reply was received. | |
Request & | request () |
Returns the request to send. | |
const Request & | request () const |
Returns the request to send. | |
Signal< Client & > & | requestSent () |
Signals that a part of the request was sent. | |
void | send (bool finished=true) |
Blocks until request is sent. | |
void | setActive (System::EventLoop &loop) |
Sets the event loop to use. | |
void | setHost (const Net::Endpoint &ep) |
Set host to connect to. | |
void | setHost (const Net::Endpoint &ep, const Net::TcpSocketOptions &opts) |
Set host to connect to. | |
void | setPeerName (const std::string &peer) |
Set expected SSL peer name. | |
void | setSecure (Ssl::Context &ctx) |
Enable to use HTTPS. | |
void | setTimeout (std::size_t timeout) |
Set timeout for I/O operations. | |
A connection will be persistent (keep-alive), if the request headers contains the keep-alive header fields. A persistent connection is needed for HTTP request pipelining. Once all requests have been made, the client should be closed, otherwise it may run into the servers keep-alive timeout, if the client is used again later.