Barracuda Application Server C/C++ Reference
NO
|
The HTTP(S) "C" client library implementation conforms to the HTTP/1.1 standard, RFC 2616.
The following example shows how to create a function that loads the response from a server that either returns static content with a known content length or from a server that returns dynamically created data using chunk encoding.
A server can send a content length or chunk encoding for dynamically generated data. We can trick the server into sending a content-length even for dynamically generated data by sending a head request. Knowing the content length makes it easier to allocate a storage buffer.
#include <HttpClient.h>
Public Member Functions | |
HttpClient (SoDisp *disp, U8 mode=HttpClient_Persistent) | |
Create a HttpClient instance. More... | |
~HttpClient () | |
Terminate the HttpClient. | |
void | setSSL (SharkSsl *ssl) |
Set the SharkSSL client object to enable https: URL's. More... | |
void | setReadTmo (BaTime timeout) |
Set the read timeout (in milliseconds). More... | |
SharkSslConTrust | trusted (void) |
Returns the peer's "trust" status. More... | |
void | setAcceptTrusted (bool acceptTrusted) |
Force method HttpClient::request to accept only trusted connections when connecting to a server. More... | |
int | request (HttpMethod methodType, const char *url, const char *userPass=0, const HttpClientKeyVal *query=0, const HttpClientKeyVal *headers=0, BaFileSize size=0) |
int | sendData (const void *data, int len) |
Send data to the server. More... | |
int | readData (void *buf, int bufSize) |
Read HTTP response data. More... | |
const char * | getHeaderValue (const char *name) |
Returns the value for the header 'name' or NULL if the header is not in the response. More... | |
HttpClientHeader * | getHeaders (int *hlen) |
Returns all HTTP response headers. More... | |
void | close () |
Close a persisten HTTP 1.1 connection. | |
int | getStatus () |
Returns the server's HTTP response code or a negative value on socket errors. | |
int | getError () |
Returns the last socket error code if any. More... | |
SharkSslCon * | getSharkSslCon () |
Wrapper for SoDispCon:getSharkSslCon. | |
Public Member Functions inherited from SoDispCon | |
int | connect (const char *host, U16 port, const void *bindIntfName=0, U16 bindPort=0, U32 timeout=1500, BaBool dgram=false, BaBool ipv6=false, char **errinfo=0) |
Connect to host/IP address. More... | |
bool | isSecure () |
Deprecated: Use getSharkSslCon(NULL). | |
bool | getSharkSslCon (SharkSslCon **sc) |
Returns true if this is an SSL connection. More... | |
bool | isValid () |
Returns true if the socket connection is valid. | |
bool | isIP6 () |
Returns true if this is an IP version 6 connection. | |
int | getPeerName (HttpSockaddr *addr, U16 *port=0) |
Returns the 'peer' IP address. More... | |
int | getSockName (HttpSockaddr *addr, U16 *port=0) |
Returns the 'sock' IP address. More... | |
char * | addr2String (HttpSockaddr *addr, char *buf, int len) |
Converts IP address to string. | |
bool | cmpAddr (HttpSockaddr *addr2) |
Compare addr with address returned by getPeerName. | |
void | setTCPNoDelay (bool enable) |
Disable the TCP delay. More... | |
struct SoDisp * | getDispatcher () |
Fetch the SoDisp object. | |
bool | hasMoreData () |
Returns true if more data on the socket. | |
bool | dispatcherHasCon () |
Returns true if connection is in the SoDisp object. | |
bool | recEvActive () |
Returns true if the connection is active in the SoDisp object. | |
bool | sendEvActive () |
Used for non blocking send. | |
Static Public Member Functions | |
static int | isURL (const char *url) |
Returns true if the URL is valid. | |