Public Member Functions | Protected Member Functions | Protected Attributes

base_http::HTTPClient Class Reference

A http client. More...

#include <libppbase/base_http/HTTPClient.h>

Inheritance diagram for base_http::HTTPClient:
base_http::HTTPServer

List of all members.

Public Member Functions

 HTTPClient (base::Socket *sock=NULL, const base::String &addr="")
 Constructor.
base::String createBoundary ()
 Creates a mime boundary.
HTTPResponsesendRequest (HTTPRequest &request)
 Sends a http request to the server and get a response back.
void setSocket (base::Socket *sock, const base::String &addr="")
 Sets the socket to the server.

Protected Member Functions

int read (base::String &rbuf)
 Reads some bytes from the remote end.
void readBody (HTTPRequest *ret)
 Reads the http body.
int readChar (char *ch)
 Reads one byte from the remote end.
HTTPResponsereadHeader (const HTTPRequest &request)
 Reads the http header.
void readHeaders (HTTPRequest *request)
 Reads the http or mime headers.

Protected Attributes

base::String _addr
 host name [and port number] of the server
size_t _cchunk
 length of current chunk
bool _chunked
 flag: chunked mode
bool _chunkend
 flag: end chunk was read
size_t _clength
 content length
size_t _cread
 number of bytes read
bool _creadeof
 flag: read until eof
base::Random _rand
 random number generator
base::Socket_sock
 TCP socket.

Detailed Description

A http client.

Author:
Christoph Schwarz
Version:
$Id: HTTPClient.h 21 2010-09-05 04:18:17Z cschwarz1 $

Constructor & Destructor Documentation

base_http::HTTPClient::HTTPClient ( base::Socket sock = NULL,
const base::String addr = "" 
)

Constructor.

Parameters:
sock the tcp socket to the server
addr the server's name and port number

Member Function Documentation

base::String base_http::HTTPClient::createBoundary (  ) 

Creates a mime boundary.

Returns:
the mime boundary
int base_http::HTTPClient::read ( base::String rbuf  )  [protected]

Reads some bytes from the remote end.

Parameters:
rbuf buffer that returns the read data
Returns:
-1=protocol error, 0=EOF, 1=success
void base_http::HTTPClient::readBody ( HTTPRequest ret  )  [protected]

Reads the http body.

Parameters:
ret the http request or response to read the body
int base_http::HTTPClient::readChar ( char *  ch  )  [protected]

Reads one byte from the remote end.

Parameters:
ch returns the read byte
Returns:
-1=protocol error, 0=EOF, 1=success
HTTPResponse* base_http::HTTPClient::readHeader ( const HTTPRequest request  )  [protected]

Reads the http header.

Parameters:
request the corresponding request
Returns:
a new http response object
void base_http::HTTPClient::readHeaders ( HTTPRequest request  )  [protected]

Reads the http or mime headers.

Parameters:
request the current http request
HTTPResponse* base_http::HTTPClient::sendRequest ( HTTPRequest request  ) 

Sends a http request to the server and get a response back.

Parameters:
request the request to send
Returns:
the response, caller must delete it
void base_http::HTTPClient::setSocket ( base::Socket sock,
const base::String addr = "" 
)

Sets the socket to the server.

Parameters:
sock the socket to the server
addr host name [and port number] of the server

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