ulxr::HttpClient Class Reference
[HTTP and HTML handling]

A simple client for an http connection. More...

#include <ulxr_http_client.h>

Collaboration diagram for ulxr::HttpClient:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 HttpClient (HttpProtocol *prot)
 Constructs a http client.
virtual ~HttpClient ()
 Destroys the http client.
void msgPUT (const Cpp8BitString &msg, const CppString &type, const CppString &resource)
 Puts content into a remote resource.
void filePUT (const CppString &filename, const CppString &type, const CppString &resource)
 Puts content into a remote resource.
Cpp8BitString msgGET (const CppString &resource)
 Gets content from a remote resource.
void fileGET (const CppString &filename, const CppString &resource)
 Gets content from a remote resource.
Cpp8BitString msgPOST (const Cpp8BitString &msg, const CppString &type, const CppString &resource)
 Gets context dependent content from a remote resource.
void doDELETE (const CppString &resource)
 Delete a remote resource.
virtual void setMessageAuthentication (const CppString &user, const CppString &pass)
 Sets username and password for the following transmissions.

Protected Member Functions

void sendAuthentication ()
 Sends the current authentiocation data over the conenction.
int getHttpStatus () const
 Gets the status value from the response.
CppString getHttpPhrase () const
 Gets the status phrase from the response.
CppString getHttpVersion () const
 Gets the version of the http protocol.
virtual void interpreteHttpHeader ()
 Processes all the http headers after the header has been completely read.
void receiveResponse (BodyProcessor &proc)
 Receives a complete response from the server.

Private Attributes

unsigned head_status
CppString head_phrase
CppString head_version
CppString http_user
CppString http_pass
HttpProtocolprotocol

Detailed Description

A simple client for an http connection.

This implementation only honors the basic http methods PUT, GET, POST and DELETE.

Definition at line 69 of file ulxr_http_client.h.


Constructor & Destructor Documentation

ulxr::HttpClient::HttpClient ( HttpProtocol prot  ) 

Constructs a http client.

Parameters:
prot pointer to an existing connection

Definition at line 71 of file ulxr_http_client.cpp.

References protocol, ulxr::HttpProtocol::setChunkedTransfer(), ULXR_PCHAR, and ULXR_TRACE.

virtual ulxr::HttpClient::~HttpClient (  )  [inline, virtual]

Destroys the http client.

Definition at line 80 of file ulxr_http_client.h.


Member Function Documentation

void ulxr::HttpClient::msgPUT ( const Cpp8BitString msg,
const CppString type,
const CppString resource 
)

Puts content into a remote resource.

Parameters:
msg content to send via http PUT
resource name of the remote resource
type the mime type of the content (e.g. text/html)

Definition at line 146 of file ulxr_http_client.cpp.

References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.

void ulxr::HttpClient::filePUT ( const CppString filename,
const CppString type,
const CppString resource 
)

Puts content into a remote resource.

Parameters:
filename file to send via http PUT
type the mime type of the content (e.g. text/html)
resource name of the remote resource

Definition at line 172 of file ulxr_http_client.cpp.

References ulxr::getLatin1(), ulxr::SystemError, ulxr::TransportError, ulxr_i18n, ULXR_PCHAR, ULXR_SEND_BUFFER_SIZE, and ULXR_TRACE.

Cpp8BitString ulxr::HttpClient::msgGET ( const CppString resource  ) 

Gets content from a remote resource.

Parameters:
resource name of the remote resource
Returns:
content to receive via http GET

Definition at line 227 of file ulxr_http_client.cpp.

References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.

void ulxr::HttpClient::fileGET ( const CppString filename,
const CppString resource 
)

Gets content from a remote resource.

Parameters:
filename filename to store the result from the http GET
resource name of the remote resource

Definition at line 271 of file ulxr_http_client.cpp.

References ulxr::getLatin1(), ulxr::SystemError, ulxr::TransportError, ulxr_i18n, ULXR_PCHAR, and ULXR_TRACE.

Cpp8BitString ulxr::HttpClient::msgPOST ( const Cpp8BitString msg,
const CppString type,
const CppString resource 
)

Gets context dependent content from a remote resource.

Usually this is used in web forms where user data is processed.

Parameters:
msg "selector" for the content to receive via http POST
type the mime type of the content (e.g. text/html)
resource name of the remote resource
Returns:
resulting content

Definition at line 297 of file ulxr_http_client.cpp.

References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.

void ulxr::HttpClient::doDELETE ( const CppString resource  ) 

Delete a remote resource.

Parameters:
resource name of the remote resource

Definition at line 325 of file ulxr_http_client.cpp.

References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.

void ulxr::HttpClient::setMessageAuthentication ( const CppString user,
const CppString pass 
) [virtual]

Sets username and password for the following transmissions.

This makes the next and all following transmission blocks use a simple authentication scheme with a username and password.

Parameters:
user Username
pass Password

Definition at line 346 of file ulxr_http_client.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

void ulxr::HttpClient::sendAuthentication (  )  [protected]

Sends the current authentiocation data over the conenction.

Definition at line 355 of file ulxr_http_client.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

int ulxr::HttpClient::getHttpStatus (  )  const [protected]

Gets the status value from the response.

Returns:
status value

Definition at line 363 of file ulxr_http_client.cpp.

CppString ulxr::HttpClient::getHttpPhrase (  )  const [protected]

Gets the status phrase from the response.

Returns:
status phrase

Definition at line 369 of file ulxr_http_client.cpp.

CppString ulxr::HttpClient::getHttpVersion (  )  const [protected]

Gets the version of the http protocol.

This method return just the numeric part after "/". For example "1.1" instead of "HTTP/1.1".

Returns:
version

Definition at line 375 of file ulxr_http_client.cpp.

void ulxr::HttpClient::interpreteHttpHeader (  )  [protected, virtual]

Processes all the http headers after the header has been completely read.

Definition at line 79 of file ulxr_http_client.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

void ulxr::HttpClient::receiveResponse ( BodyProcessor proc  )  [protected]

Receives a complete response from the server.

Parameters:
proc pointer to a helper instance to process the message body.

Definition at line 90 of file ulxr_http_client.cpp.

References ulxr::Protocol::ConnBody, ulxr::Protocol::ConnError, ulxr::Protocol::ConnSwitchToBody, ulxr::TransportError, ulxr_i18n, ULXR_PCHAR, ULXR_RECV_BUFFER_SIZE, and ULXR_TRACE.


Member Data Documentation

unsigned ulxr::HttpClient::head_status [private]

Definition at line 172 of file ulxr_http_client.h.

CppString ulxr::HttpClient::head_phrase [private]

Definition at line 173 of file ulxr_http_client.h.

CppString ulxr::HttpClient::head_version [private]

Definition at line 174 of file ulxr_http_client.h.

CppString ulxr::HttpClient::http_user [private]

Definition at line 175 of file ulxr_http_client.h.

CppString ulxr::HttpClient::http_pass [private]

Definition at line 176 of file ulxr_http_client.h.

HttpProtocol* ulxr::HttpClient::protocol [private]

Definition at line 178 of file ulxr_http_client.h.

Referenced by HttpClient().


The documentation for this class was generated from the following files:
Generated on Sun Aug 19 20:09:05 2007 for ulxmlrpcpp by  doxygen 1.5.1