MoSync 3.3
MAUtil::HttpConnection Class Reference

This class describes a single HTTP 1.0 operation. More...

#include <MAUtil/Connection.h>

Inheritance diagram for MAUtil::HttpConnection:
MAUtil::Connection MAUtil::ConnListener Wormhole::HighLevelHttpConnection Wormhole::HighLevelBinaryDownloader Wormhole::HighLevelImageDownloader Wormhole::HighLevelTextDownloader

List of all members.

Public Member Functions

 HttpConnection (HttpConnectionListener *listener)
int create (const char *url, int method)
void setRequestHeader (const char *key, const char *value)
int getResponseHeader (const char *key, String *str)
void finish ()
int connect (const char *url)
void close ()
void write (const void *src, int len)
void writeFromData (MAHandle data, int offset, int len)
void writeTo (const void *src, int len, const MAConnAddr &dst)
void recv (void *dst, int maxlen)
void recvToData (MAHandle data, int offset, int maxlen)
void recvFrom (void *dst, int maxlen, MAConnAddr *src)
void read (void *dst, int len)
void readToData (MAHandle data, int offset, int len)
void setListener (ConnectionListener *listener)
bool isOpen () const
int getAddr (MAConnAddr *dst)

Protected Member Functions

virtual void connEvent (const MAConnEventData &data)
void recvMem (int prevRes)
void recvData (int prevRes)

Protected Attributes

MAHandle mConn
ConnectionListenermListener
int mRemain
bytemDst
MAHandle mData
int mOffset
void(Connection::* mRecv )(int prevRes)

Detailed Description

This class describes a single HTTP 1.0 operation.


Constructor & Destructor Documentation


Member Function Documentation

int MAUtil::HttpConnection::create ( const char *  url,
int  method 
)
Returns:
>0 on success, or a CONNERR code < 0 on failure.
See also:
maHttpCreate
void MAUtil::HttpConnection::setRequestHeader ( const char *  key,
const char *  value 
)
int MAUtil::HttpConnection::getResponseHeader ( const char *  key,
String str 
)

Stores an HTTP response header value in a String, if the header exists. Resizes the String appropriately. Does not modify the String if the header does not exist.

Returns:
The length of the header value, or CONNERR_NOHEADER if the header doesn't exist.
See also:
maHttpGetResponseHeader

This function returns immediately. When the operation is complete, httpFinished() of the HttpConnectionListener associated with this HttpConnection will be called.

See also:
maHttpFinish
virtual void MAUtil::HttpConnection::connEvent ( const MAConnEventData data) [protected, virtual]

Reimplemented from MAUtil::Connection.

int MAUtil::Connection::connect ( const char *  url) [inherited]

Reimplemented in MAUtil::BluetoothConnection.

void MAUtil::Connection::close ( ) [inherited]

Closes the connection, if open. Frees all resources allocated by this object. Allows this Connection object to be reused for further connections.

See also:
maConnClose()

Reimplemented in MAUtil::BluetoothConnection.

void MAUtil::Connection::write ( const void *  src,
int  len 
) [inherited]

Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.

See also:
maConnWrite()
Warning:
The source data must remain available until the operation is complete, so don't use local variables as input.
void MAUtil::Connection::writeFromData ( MAHandle  data,
int  offset,
int  len 
) [inherited]

Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.

See also:
maConnWriteFromData()
void MAUtil::Connection::writeTo ( const void *  src,
int  len,
const MAConnAddr dst 
) [inherited]

Causes ConnectionListener::connWriteFinished() to be called when the operation is complete.

See also:
maConnWriteTo() dst may be discarded once this function returns.
void MAUtil::Connection::recv ( void *  dst,
int  maxlen 
) [inherited]

Reads between 1 and maxlen bytes to dst. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete. Use this function when you don't care how much data you get, as long as you get something.

void MAUtil::Connection::recvToData ( MAHandle  data,
int  offset,
int  maxlen 
) [inherited]

Reads between 1 and maxlen bytes to data, starting at offset. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete.

void MAUtil::Connection::recvFrom ( void *  dst,
int  maxlen,
MAConnAddr src 
) [inherited]

Reads between 1 and maxlen bytes to dst. Stores the sender address in src. Causes ConnectionListener::connRecvFinished() to be called when the operation is complete.

Warning:
src must remain valid until the operation is complete.
See also:
maConnReadFrom()
void MAUtil::Connection::read ( void *  dst,
int  len 
) [inherited]

Reads exactly len bytes to dst. Causes ConnectionListener::connReadFinished() to be called when the operation is complete. Use this function when you know exactly how much data you want, and are not interested in anything less.

void MAUtil::Connection::readToData ( MAHandle  data,
int  offset,
int  len 
) [inherited]

Reads exactly len bytes to data, starting at offset. Causes ConnectionListener::connReadFinished() to be called when the operation is complete.

void MAUtil::Connection::setListener ( ConnectionListener listener) [inherited]

Replaces the listener for this object.

Warning:
If you do this while an operation is active, the new listener will recieve the callback, not the old one. This may break your program if it is not aware.
bool MAUtil::Connection::isOpen ( ) const [inherited]

Returns true if the connection is open, false otherwise. The connection is considered open even during the connect() operation.

int MAUtil::Connection::getAddr ( MAConnAddr dst) [inherited]

Retrieves the remote address of this connection.

Returns:
> 0 on success, < 0 on error.
void MAUtil::Connection::recvMem ( int  prevRes) [protected, inherited]
void MAUtil::Connection::recvData ( int  prevRes) [protected, inherited]

Member Data Documentation

MAHandle MAUtil::Connection::mConn [protected, inherited]
int MAUtil::Connection::mRemain [protected, inherited]
byte* MAUtil::Connection::mDst [protected, inherited]
MAHandle MAUtil::Connection::mData [protected, inherited]
int MAUtil::Connection::mOffset [protected, inherited]
void(Connection::* MAUtil::Connection::mRecv)(int prevRes) [protected, inherited]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines