#include <cel_http.h>

Public Member Functions | |
| virtual AutoPtr< HttpConnection > | createConnection (const String &inHostName, u16 inPort=80)=0 |
| virtual AutoPtr< HttpConnection > | createSecureConnection (const String &inHostName, u16 inPort=443, bool inVerifyServer=false)=0 |
| virtual AutoPtr< HttpStorage > | createHttpStorage (const String &inUrl, bool inVerifyServer=false, DuplicateStreamCallback inLoadCallback=NULL, void *inContext=NULL) |
| virtual void | setProxy (ProxyType inType, const String &inHostName="", u16 inPort=0)=0 |
| virtual CredentialProvider * | getCredentialProvider ()=0 |
Static Public Member Functions | |
| static AutoPtr< HttpManager > | create (const String &inUserAgentName=NullString, CredentialProvider *inCredentialProvider=NULL) |
| static String | getDefaultUserAgentName () |
| static String | getUserAgentPlatformSpec () |
http://www.celartem.com .
void fetchPage(SimpleArray<u8>& buffer) { // This client does not support any authentication mechanism. Autoptr<HttpManager> httpMan = HttpManager::create("Simple HTTP Test/1.0"); // If you have only URL, not hostname, use // Url::separateUrl function. AutoPtr<HttpConnection> conn = httpMan->createConnection("www.celartem.com"); // fetch "/" AutoPtr<HttpRequestStream> req = conn->createRequestStream("GET", "/"); // get the response AutoPtr<HttpResponseStream> res = req->post(); // check status unsigned int ret = res->getStatusCode(); if(ret / 100 != 2) celThrow(errOperationFailed); // non 2XX response // load the content size_t size = res->getContentSize(); buffer.allocate(size); res->readBytes(&buffer[0], size); }
Please note that this sample is just to indicate how to use createConnection, HttpRequestStream and HttpResponseStream, there are another way to do it easier; for more information, see createHttpStorage .
Definition at line 101 of file cel_http.h.
| virtual AutoPtr<HttpConnection> Celartem::HttpManager::createConnection | ( | const String & | inHostName, | |
| u16 | inPort = 80 | |||
| ) | [pure virtual] |
This method does create a connection object between this machine and the specified host. This method is thread-safe; all the calls to this method is automatically serialized.
| inHostName | It specifies the remote host to connect, it could be string notation of hostname or dotted-decimal style IP address such as "192.168.10.23". If you only want to fetch a resource (file) from Web, you had better use createHttpStorage instead of this method. | |
| inPort | It specifies the port to connect. HTTP (non-secure connection) uses 80 by default. 0 to use the default (80). |
| virtual AutoPtr<HttpConnection> Celartem::HttpManager::createSecureConnection | ( | const String & | inHostName, | |
| u16 | inPort = 443, |
|||
| bool | inVerifyServer = false | |||
| ) | [pure virtual] |
This method does create a secure connection object between this machine and the specified host. This method is thread-safe; all the calls to this method is automatically serialized.
| inHostName | It specifies the remote host to connect, it could be string notation of hostname or dotted-decimal style IP address such as "192.168.10.23".If you only want to fetch a resource (file) from Web, you had better use createHttpStorage instead of this method. | |
| inPort | It specifies the port to connect. HTTPS (Secure HTTP connection) uses 443 by default. 0 to use the default (443). | |
| inVerifyServer | Whether the server connected to should be verified or not. | |
| inLoadCallback | A callback which is called when the load call takes long. | |
| inContext | A context for the callback. |
| virtual AutoPtr<HttpStorage> Celartem::HttpManager::createHttpStorage | ( | const String & | inUrl, | |
| bool | inVerifyServer = false, |
|||
| DuplicateStreamCallback | inLoadCallback = NULL, |
|||
| void * | inContext = NULL | |||
| ) | [virtual] |
This method create read-only storage based on HTTP connection. Whether using HTTP or HTTPS is automatically determined by examining scheme specification in the URL.
The storage created by this method internally uses HttpConnection. This method is thread-safe; all the calls to this method is automatically serialized.
| inUrl | URL of the resource to access. It should be escaped before passing to this method. | |
| inVerifyServer | Whether the server connected to should be verified or not. |
void fetchPage(SimpleArray<u8>& buffer) { // This client does not support any authentication mechanism. AutoPtr<HttpManager> httpMan = HttpManager::create("Simple HTTP Test/1.0"); AutoPtr<HttpStorage> storage = httpMan->createHttpStorage("http://www.example.com/test/picture.tif"); // load the content size_t size = storage->getSize(); buffer.allocate(size + 1); storage->readBytes(&buffer[0], size); buffer[size] = 0; }
| virtual void Celartem::HttpManager::setProxy | ( | ProxyType | inType, | |
| const String & | inHostName = "", |
|||
| u16 | inPort = 0 | |||
| ) | [pure virtual] |
This function changes the current settings for the HTTP proxy.
| inType | One of the ProxyType enumerations. | |
| inHostName | Any string notation of the proxy server host; it is only required with proxyManual. | |
| inPort | Port number of the proxy server; it is only required with proxyManual. |
| virtual CredentialProvider* Celartem::HttpManager::getCredentialProvider | ( | ) | [pure virtual] |
This function returns associated CredentialProvider instance.
| static AutoPtr<HttpManager> Celartem::HttpManager::create | ( | const String & | inUserAgentName = NullString, |
|
| CredentialProvider * | inCredentialProvider = NULL | |||
| ) | [static] |
This method creates an HttpManager instance that uses the specified configuration. It also initializes the network environment if needed. You should synchronize creation of the requests; only 1 request can exist at a time on a connection.
This method is thread-safe; all the calls to this method is automatically serialized.
| inUserAgentName | User Agent Name for your application. If this value is not specified (or NullString), it uses system default. | |
| inCredentialProvider | Pointer to a class instance to get credential information. |
| static String Celartem::HttpManager::getDefaultUserAgentName | ( | ) | [static] |
This method returns the default user agent name.
| static String Celartem::HttpManager::getUserAgentPlatformSpec | ( | ) | [static] |
This method returns the user agent platform specifications, which is used in the default user agent name.