Mixes for Privacy and Anonymity in the Internet
|
Very simple http client. More...
Public Member Functions | |
CAHttpClient (CASocket *pSocket) | |
CAHttpClient () | |
~CAHttpClient () | |
SINT32 | setSocket (CASocket *pSocket) |
SINT32 | sendGetRequest (const UINT8 *url) |
Sends a HTTP GET request to the server. More... | |
SINT32 | sendPostRequest (const UINT8 *url, const UINT8 *data, const UINT32 dataLen) |
Sends a HTTP POST request to the server. More... | |
SINT32 | parseHTTPHeader (UINT32 *contentLength, UINT32 *statusCode=NULL, UINT32 msTimeOut=3000) |
receives the HTTP header and parses the content length More... | |
SINT32 | getContent (UINT8 *a_pContent, UINT32 *a_pLength) |
Retruns the content of the response. More... | |
Private Attributes | |
CASocket * | m_pSocket |
the socket connection to the http server More... | |
Very simple http client.
Used by CAInfoService and CAAccountingBIInterface. Must be initialized with a connected socket. Note that the socket is still owned by the caller. CAHttpClient will not delete the socket
CAHttpClient::CAHttpClient | ( | ) |
References m_pSocket.
CAHttpClient::~CAHttpClient | ( | ) |
Retruns the content of the response.
Gets the content of a HTTP response.
a_pContent | buff which receives the content |
a_pLength | on input contains the size of a_pContent, on return contains the number of received bytes |
E_NOT_CONNECTED | if socket is not connected |
E_SUCCESS | if successful |
References E_NOT_CONNECTED, E_SUCCESS, len, m_pSocket, and CASocket::receive().
Referenced by CAInfoService::getPaymentInstance().
SINT32 CAHttpClient::parseHTTPHeader | ( | UINT32 * | contentLength, |
UINT32 * | statusCode = NULL , |
||
UINT32 | msTimeOut = 3000 |
||
) |
receives the HTTP header and parses the content length
Receives the HTTP header and parses the content length.
contentLength | receives the parsed content length |
statusCode | if set, receives the http statuscode (200, 403, 404, ...) |
E_SUCCESS | if all is OK |
E_UNKNOWN | if the server returned a http errorcode TODO: Verify that "HTTP/1.1 200 OK" must be the first line! |
contentLength | receives the parsed content length |
statusCode | if set, receives the http statuscode (200, 403, 404, ...) |
msTimeOut | time in ms for receiving the HTTPHeader (<=0 means no timeout) |
E_SUCCESS | if all is OK |
E_NOT_CONNECTED | if the connection to the Web-Server was lost |
E_UNKNOWN | if the server returned a http errorcode, in this case statusCode is set to 0 and contentLength is set to 0 |
: Verify that "HTTP/1.1 200 OK" must be the first line!
: Maybe set an other statusCode in case of an error ?
TODO: do it better (case insensitive compare!)
References add64(), diff64(), E_AGAIN, E_NOT_CONNECTED, E_SUCCESS, E_TIMEDOUT, E_UNKNOWN, getcurrentTimeMillis(), CASocket::getNonBlocking(), isLesser64(), m_pSocket, msSleep(), CAMsg::printMsg(), CASocket::receive(), set64(), and CASocket::setNonBlocking().
Referenced by CAInfoService::getPaymentInstance(), CAInfoService::sendMixHelo(), CAAccountingBIInterface::settle(), and CAAccountingBIInterface::settleAll().
Sends a HTTP GET request to the server.
url | the local part of the URL requested (e.g. "/settle") |
url | the local part of the URL requested (e.g. "/settle") |
E_UNKNOWN | on socket errors |
E_NOT_CONNECTED | if the connection was lost |
E_SUCCESS | if all is OK |
References E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, len, m_pSocket, CAMsg::printMsg(), and CASocket::sendFullyTimeOut().
Referenced by CAInfoService::getPaymentInstance().
SINT32 CAHttpClient::sendPostRequest | ( | const UINT8 * | url, |
const UINT8 * | data, | ||
const UINT32 | dataLen | ||
) |
Sends a HTTP POST request to the server.
url | the local part of the requested URL (e.g. "/settle") |
data | a buffer containing the data |
dataLen | the length of the data in bytes |
References data, E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, len, m_pSocket, CAMsg::printMsg(), and CASocket::sendFullyTimeOut().
Referenced by CAAccountingBIInterface::settle(), and CAAccountingBIInterface::settleAll().
References E_SUCCESS, and m_pSocket.
Referenced by CAInfoService::getPaymentInstance(), CAAccountingBIInterface::initBIConnection(), and CAInfoService::sendMixHelo().
|
private |
the socket connection to the http server
Referenced by CAHttpClient(), getContent(), parseHTTPHeader(), sendGetRequest(), sendPostRequest(), and setSocket().