Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::Net::HTTPClientSession Class Reference

#include <HTTPClientSession.h>

Inheritance diagram for Poco::Net::HTTPClientSession:

Poco::Net::HTTPSession Poco::Net::HTTPSClientSession

List of all members.

Detailed Description

This class implements the client-side of a HTTP session.

To send a HTTP request to a HTTP server, first instantiate a HTTPClientSession object and specify the server's host name and port number.

Then create a HTTPRequest object, fill it accordingly, and pass it as argument to the sendRequst() method.

sendRequest() will return an output stream that can be used to send the request body, if there is any.

After you are done sending the request body, create a HTTPResponse object and pass it to receiveResponse().

This will return an input stream that can be used to read the response body.

See RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html> for more information about the HTTP protocol.

Definition at line 58 of file HTTPClientSession.h.

Public Types

enum  { HTTP_PORT = 80 }

Public Member Functions

void abort ()
 Returns true if the underlying socket is connected.
bool connected () const
 Returns the timeout for the HTTP session.
const std::string & getHost () const
bool getKeepAlive () const
Poco::UInt16 getPort () const
const std::string & getProxyHost () const
 Sets the port number of the proxy server.
Poco::UInt16 getProxyPort () const
 Returns the proxy host name.
Poco::Timespan getTimeout () const
 Sets the timeout for the HTTP session.
 HTTPClientSession (const std::string &host, Poco::UInt16 port=HTTPSession::HTTP_PORT)
 Creates a HTTPClientSession using the given address.
 HTTPClientSession (const SocketAddress &address)
 HTTPClientSession (const StreamSocket &socket)
 Creates an unconnected HTTPClientSession.
const Poco::ExceptionnetworkException () const
virtual std::istream & receiveResponse (HTTPResponse &response)
virtual std::ostream & sendRequest (HTTPRequest &request)
 Returns the proxy port number.
void setHost (const std::string &host)
void setKeepAlive (bool keepAlive)
void setPort (Poco::UInt16 port)
 Returns the host name of the target HTTP server.
void setProxy (const std::string &host, Poco::UInt16 port=HTTPSession::HTTP_PORT)
 Returns the port number of the target HTTP server.
void setProxyHost (const std::string &host)
 Sets the proxy host name and port number.
void setProxyPort (Poco::UInt16 port)
 Sets the host name of the proxy server.
void setTimeout (const Poco::Timespan &timeout)
virtual ~HTTPClientSession ()
 Creates a HTTPClientSession using the given host and port.

Protected Member Functions

void close ()
virtual void connect (const SocketAddress &address)
 Refills the internal buffer.
void deleteRequestStream ()
 Deletes the response stream and sets it to 0.
void deleteResponseStream ()
 Returns the target host and port number for proxy requests.
int get ()
bool getExpectResponseBody () const
 Sets _expectResponseBody.
virtual std::string getHostInfo () const
 Tries to re-connect if keep-alive is on.
std::ostream * getRequestStream () const
 Returns the currently set response stream. Can return 0.
std::istream * getResponseStream () const
 Sets the request stream iff _pRequestStream is 0.
int peek ()
virtual int read (char *buffer, std::streamsize length)
int receive (char *buffer, int length)
 Writes data to the socket.
void reconnect ()
void refill ()
 Returns a reference to the underlying socket.
void setException (const Poco::Exception &exc)
 Closes the underlying socket.
void setExpectResponseBody (bool expect)
 Sets _reconnect.
void setReconnect (bool recon)
 Returns the currently set request stream. Can return 0.
void setRequestStream (std::ostream *pRequestStream)
 Sets the response stream iff _pResponseStream is 0.
void setResponseStream (std::istream *pRespStream)
 Deletes the request stream and sets it to 0.
StreamSocketsocket ()
 Reads up to length bytes.
int write (const char *buffer, std::streamsize length)
 Connects the underlying socket to the HTTP server.

Private Attributes

bool _expectResponseBody
std::string _host
 Returns _expectResponseBody.
bool _mustReconnect
Poco::UInt16 _port
std::ostream * _pRequestStream
std::istream * _pResponseStream
std::string _proxyHost
Poco::UInt16 _proxyPort
bool _reconnect

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

Generated by  Doxygen 1.6.0   Back to index