rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWHttpClient Class Reference
[HTTP]

Provides a low-level interface for communicating with an HTTP server. More...

#include <rw/http/RWHttpClient.h>

Inheritance diagram for RWHttpClient:
RWHandleBase RWHttpSocketClient RWHttpsSecureSocketClient

List of all members.

Public Member Functions

 RWHttpClient (void)
 RWHttpClient (const RWHttpClient &client)
RWHttpClientoperator= (const RWHttpClient &other)
virtual ~RWHttpClient ()
void connect (const RWSockAddrBase &address, unsigned long maxwait=0)
bool submit (RWHttpRequest request, RWHttpPipeline pl=RW_HTTP_FORBID_PIPELINING, unsigned long maxwait=0)
RWHttpReply getReply (unsigned long maxwait=0)
RWHttpReply getReply (RWTFunctor1< RWPortal > handler, unsigned long maxwait=0)
RWHttpReply getReply (RWTFunctor2< RWPortal, RWHttpReply & > handler, unsigned long maxwait=0)
bool isConnected () const

Protected Member Functions

 RWHttpClient (RWHttpClientImp *imp)
RWHttpClientImp & body () const

Detailed Description

RWHttpClient, along with helper RWHttpMethod classes, enables detailed control over HTTP communications. The asynchronous nature of HTTP/1.1 enables you to submit multiple requests to the server before retrieving any of the replies. Replies are returned in the same order that they are submitted.

RWHttpClient objects are lightweight. They are implemented using the handle-body pattern. The RWHttpClient is a handle to an implementation that performs the protocol interaction.


Constructor & Destructor Documentation

RWHttpClient::RWHttpClient ( RWHttpClientImp *  imp  )  [inline, protected]

Protected constructor from imp.

RWHttpClient::RWHttpClient ( void   )  [inline]

Constructs a default RWHttpClient object.

RWHttpClient::RWHttpClient ( const RWHttpClient client  )  [inline]

Copy constructor. The body of the new client is the same as client.

virtual RWHttpClient::~RWHttpClient (  )  [virtual]

Virtual destructor.


Member Function Documentation

RWHttpClientImp & RWHttpClient::body ( void   )  const [inline, protected]

Returns a reference to the body.

Reimplemented from RWHandleBase.

Reimplemented in RWHttpSocketClient, and RWHttpsSecureSocketClient.

void RWHttpClient::connect ( const RWSockAddrBase address,
unsigned long  maxwait = 0 
) [inline]

Enables an HTTP client to establish a connection session with an HTTP server. The address argument specifies the address of the server to connect to.

The optional value maxwait specifies how long the RWHttpClient waits for data to become available on a socket before deciding that the socket is dead. maxwait defaults to 0, which specifies that RWHttpClient waits indefinitely for data. If the maxwait time expires, an RWNetOperationTimeoutError exception is thrown.

RWHttpReply RWHttpClient::getReply ( RWTFunctor2< RWPortal, RWHttpReply & >  handler,
unsigned long  maxwait = 0 
) [inline]

Equivalent to getReply(RWTFunctor1<RWPortal>, unsigned long), however this method also receives a reference to the RWHttpReply instance that is returned when the function completes. This method allows the user to access the headers and status of the message while processing the body.

RWHttpReply RWHttpClient::getReply ( RWTFunctor1< RWPortal handler,
unsigned long  maxwait = 0 
) [inline]

Returns the next reply from the server. The reply contains the status code and headers for the reply. A portal containing the body of the message is passed to the user-defined handler. If the message is not read fully from the portal by the handler, an RWHttpHandlerError exception is thrown.

The optional value maxwait is the number of milliseconds that the RWHttpClient waits for data to become available on a socket before deciding that the socket is dead. maxwait defaults to 0, which specifies that RWHttpClient waits indefinitely for data. If the maxwait time expires, an RWNetOperationTimeoutError exception is thrown.

RWHttpReply RWHttpClient::getReply ( unsigned long  maxwait = 0  )  [inline]

Returns the next response from the server. The response contains the status code and headers, plus the body of the response as an RWCString.

The optional value maxwait is the number of milliseconds that the RWHttpClient waits for data to become available on a socket before deciding that the socket is dead. maxwait defaults to 0, which specifies that RWHttpClient waits indefinitely for data. If the maxwait time expires, an RWNetOperationTimeoutError exception is thrown.

bool RWHttpClient::isConnected (  )  const [inline]

Returns true if the client was last known to be connected to an HTTP server. Otherwise returns false.

A return of true does not guarantee that the client is currently connected to the server. true indicates only the state of the connection after the last read or write attempt. For example, if the server silently closed the connection, this function returns true.

RWHttpClient & RWHttpClient::operator= ( const RWHttpClient other  )  [inline]

Assigns the body of other to this. Any previous bodies associated with this RWHttpClient object are released.

bool RWHttpClient::submit ( RWHttpRequest  request,
RWHttpPipeline  pl = RW_HTTP_FORBID_PIPELINING,
unsigned long  maxwait = 0 
) [inline]

Returns true if it successfully submits a request to the server. Otherwise returns false. If pl is equal to RW_HTTP_ALLOW_PIPELINING, the client assumes that it is safe to pipeline the request. For information about pipelining, see the Internet Protocols Module User's Guide.

The optional value maxwait is the number of milliseconds that the RWHttpClient waits for data to become available on a socket before deciding that the socket is dead. maxwait defaults to 0, which specifies that RWHttpClient waits indefinitely for data. If the maxwait time expires, an RWNetOperationTimeoutError exception is thrown.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.