#include <http.h>
Inheritance diagram for OW32::CHTTP:
Public Types | |
enum | HTTP_OPTIONS { OPT_FOLLOW_REDIRECT = 1, OPT_KEEP_ALIVE = 2 } |
Options that modify the requestor's behaviour. More... | |
Public Member Functions | |
void | Reset () |
Return the object to the default state. This allows CHTTP objects to be pooled and reused. | |
void | setListener (CHTTPListener *listener) |
Set the event notification object (see #CHTTPListener). | |
CHTTPListener * | getListener () |
Return a pointer to the current listener object. | |
void | close () |
Close the current HTTP connection nicely. | |
void | abort () |
Abort the current HTTP connection. | |
std::string | lastErrorMessage () |
Return the last error, formatted up as a message. | |
int | lastError () const |
Return the last error code, from #HTTP_ERRORS. | |
DWORD | lastAPIError () const |
Return the last API error code. | |
bool | isOptionSet (int opt) const |
See if an option has set. | |
bool | getOption (int opt) const |
See if an option is set. | |
int | setOption (int opt) |
Set an option. | |
void | clearOption (int opt) |
Clear an option. | |
int | setOptions (int opt) |
Set all option flags to the given mask. | |
int | getOptions () const |
Return the options mask. | |
int | setMaximumResponseSize (int maxResponseSize) |
Set the maximum size of the result document. | |
int | getMaximumResponseSize () const |
Return the current maximum result size. | |
int | setTimeout (int timeout) |
Set the TCP timeouts for send() and recv(). | |
int | getTimeout () const |
Return the current TCP timeout. | |
int | setMaximumRedirects (int maxRedirects) |
Set the maximum number of redirects to be followed. | |
int | getMaximumRedirects () const |
Get the maximum number of redirects to be followed. | |
CURIComponents & | getURI () |
Get the current URI in component form. | |
void | setURI (const CURIComponents &URI) |
Set the current URI in component form. | |
void | setProxyServer (const char *proxyServer) |
Set the proxy server to the given DNS name. | |
const std::string & | getProxyServer () const |
Get the remote ProxyServer's name. | |
void | setProxyPort (int proxyPort) |
Set the proxy server's port. | |
int | getProxyPort () const |
Get the remote ProxyPort's name. | |
void | parseURI (const char *URIString, std::string::size_type URILength) |
Parse the given URI. | |
void | parseURI (const std::string &URIString) |
Parse the given URI. | |
std::string | getCanonicalURI () const |
Get the canonical URI for the current URI. | |
auto_byte_buf & | getRequest () |
Return the request buffer. You can write into this directly for a custom HTTP request. | |
int | getStatusCode () const |
Return the last HTTP status code. | |
bool | isResponseValid () const |
See if there is a valid HTTP response stored by the object. | |
const unsigned char * | getResponse () const |
Return a pointer to the entire response. The response is as seen from the server, and therfore is NOT null terminated. | |
unsigned char * | detachResponse () |
Detach the response buffer The caller owns this buffer and should call free() on it eventually. | |
size_t | getResponseLength () const |
Return the length of the response. | |
size_t | getHeaderLength () const |
Return the length of the headers. | |
const unsigned char * | getBody () const |
Return a pointer to the body portion of the response, or NULL if none. | |
size_t | getBodyOffset () const |
Return the offset of the body data within the response, or 0 if no content was received. | |
size_t | getBodyLength () const |
Return the length of the body data. | |
size_t | getTrailerOffset () const |
Return the offset of the trailer, or 0 if no trailer is present. | |
size_t | getTrailerLength () const |
Return the length of the trailer. | |
int | connect (AsyncIoType tAsyncIo, HANDLE hCompletionPort=NULL) |
Connect to the given server or proxy (oops, deleted proxy support - TODO: put it back in). | |
int | makeRequest (bool fInitial=true) |
Begin an asynchronous HTTP request. To get anything useful out of this you ought to have set a listener first. | |
void | addHeader (const char *header) |
Add a header (used in formatGETRequest). | |
int | formatGETRequest () |
Format a simple get request into the request buffer. | |
bool | isConnected () const |
See if the object is connected. | |
unsigned char * | getHeader (const char *header) |
Search for a HTTP header in the response. | |
std::string | getHeaderValue (const char *header) |
Return a header value, or "" if the header is not found. | |
Static Public Member Functions | |
int | initialise () |
Called to initialise the requestor library. | |
void | terminate () |
Called to shutdown the requestor library. | |
CHTTP * | createObject () |
Create a CHTTP object. | |
void | urlEncode (auto_byte_buf &out, const unsigned char *data, int len) |
urlEncode a given byte string | |
unsigned char * | findLineEnd (const unsigned char *start, const unsigned char *end) |
Utility function to find the end of a line in HTTP headers. | |
Friends | |
class | CConnectionThread |
For asynchronous connection notification. |
|
Options that modify the requestor's behaviour.
|
|
Add a header (used in formatGETRequest).
|
|
Clear an option.
|
|
Create a CHTTP object.
|
|
Utility function to find the end of a line in HTTP headers.
|
|
Format a simple get request into the request buffer.
|
|
Get the canonical URI for the current URI.
|
|
Search for a HTTP header in the response.
|
|
Return a header value, or "" if the header is not found.
|
|
Return a pointer to the current listener object.
|
|
Get the maximum number of redirects to be followed.
|
|
Return the current maximum result size.
|
|
See if an option is set.
|
|
Return the options mask.
|
|
Get the remote ProxyPort's name.
|
|
Get the remote ProxyServer's name.
|
|
Return the last HTTP status code.
|
|
Return the current TCP timeout.
|
|
Called to initialise the requestor library.
|
|
See if the object is connected.
|
|
See if an option has set.
|
|
See if there is a valid HTTP response stored by the object. This is the case if: a) We have a complete set of headers b) There was no I/O error Should only be called after the object is quiesced. |
|
Return the last error, formatted up as a message.
|
|
Begin an asynchronous HTTP request. To get anything useful out of this you ought to have set a listener first.
|
|
Parse the given URI.
|
|
Parse the given URI.
|
|
Set the event notification object (see #CHTTPListener).
The lifetime of the listener follows the same rules. |
|
Set the maximum number of redirects to be followed.
|
|
Set the maximum size of the result document.
If maxResponseSize is zero, then no limit is set. The response size does not include the headers. The response size is also approximate -- the intention is to prevent fetches of _enormous_ documents (the tolerance will be within the chunk size, defaulting to 4K). |
|
Set an option.
|
|
Set all option flags to the given mask.
|
|
Set the proxy server's port.
|
|
Set the proxy server to the given DNS name.
|
|
Set the TCP timeouts for send() and recv().
|
|
urlEncode a given byte string
|