41#include <SharkSslEx.h>
111#define HttpClientHeader_key(c,o) ((c)->db.super.buf + (o)->key)
112#define HttpClientHeader_val(c,o) ((c)->db.super.buf + (o)->val)
115#define HTTP_CLIENT_MAX_HEADERS 64
117#define HttpClient_SocksProxy 1
118#define HttpClient_ProxyConnect 2
119#define HttpClient_Persistent 4
120#define HttpClient_IPv6 8
122#define HttpClient_NoHostHeader 16
123#define HttpClient_NotUsed2 32
125#define HttpClient_UserDef1 64
126#define HttpClient_UserDef2 128
239 void setSSL(SharkSsl* ssl);
247 static int isURL(
const char* url);
254 SharkSslConTrust
trusted(
void);
295 const char* userPass=0,
310 int sendData(
const void* data,
int len);
318 int readData(
void* buf,
int bufSize);
366 struct SharkSsl* sharkSslClient;
372 const char* proxyUserPass;
373 const char* intfName;
385 BaBool chunkEncoding;
388 BaBool acceptTrusted;
403#define HttpClient_setSSL(o, ssl) (o)->sharkSslClient=ssl
404#define HttpClient_setReadTmo(o, timeout) (o)->readTmo=timeout
406SharkSslCon* HttpClient_getSharkSslCon(
HttpClient* o);
410int HttpClient_isURL(
const char* url);
414 const char* userPass,
419int HttpClient_sendData(
HttpClient* o,
const void* data,
int len);
421int HttpClient_readDataBuffered(
HttpClient* o,
void* buf,
int bufSize);
422int HttpClient_readData(
HttpClient* o,
void* buf,
int bufSize);
423const char* HttpClient_getHeaderValue(
HttpClient* o,
const char* name);
427#define HttpClient_getError(o) (o)->lastError
428#define HttpClient_getSoDispCon(o) ((SoDispCon*)(o))
430SharkSslConTrust HttpClient_trusted(
HttpClient* o);
432#define HttpClient_setAcceptTrusted(o, t) (o)->acceptTrusted=t
438 HttpClient_constructor(
this,disp, mode);
442 HttpClient_destructor(
this);
446 HttpClient_setSSL(
this,ssl);
450 HttpClient_setReadTmo(
this,timeout);
454 return HttpClient_isURL(url);
459 return HttpClient_trusted(
this);
463 HttpClient_setAcceptTrusted(
this, t?TRUE:FALSE);
468 return HttpClient_getSharkSslCon(
this);
474 const char* userPass,
479 return HttpClient_request(
this,methodType,url,userPass,params,headers,size);
483 return HttpClient_sendData(
this, data, len);
486inline int HttpClient::getBufSize() {
487 return HttpClient_getBufSize(
this);
491 return HttpClient_readData(
this, buf, bufSize);
495 return HttpClient_getHeaderValue(
this, name);
499 return HttpClient_getHeaders(
this, hlen);
503 HttpClient_close(
this);
507 return HttpClient_getStatus(
this);
512 return HttpClient_getError(
this);
515inline SoDispCon* HttpClient::getSoDispCon() {
516 return HttpClient_getSoDispCon(
this);
520 return c->db.buf + key;
523 return c->db.buf + val;
static int isURL(const char *url)
Returns true if the URL is valid.
Definition: HttpClient.h:453
int readData(void *buf, int bufSize)
Read HTTP response data.
Definition: HttpClient.h:490
void setSSL(SharkSsl *ssl)
Set the SharkSSL client object to enable https: URL's.
Definition: HttpClient.h:445
~HttpClient()
Terminate the HttpClient.
Definition: HttpClient.h:441
void close()
Close a persisten HTTP 1.1 connection.
Definition: HttpClient.h:502
HttpClientHeader * getHeaders(int *hlen)
Returns all HTTP response headers.
Definition: HttpClient.h:498
int sendData(const void *data, int len)
Send data to the server.
Definition: HttpClient.h:482
int request(HttpMethod methodType, const char *url, const char *userPass=0, const HttpClientKeyVal *query=0, const HttpClientKeyVal *headers=0, BaFileSize size=0)
Definition: HttpClient.h:472
const char * getHeaderValue(const char *name)
Returns the value for the header 'name' or NULL if the header is not in the response.
Definition: HttpClient.h:494
SharkSslCon * getSharkSslCon()
Wrapper for SoDispCon:getSharkSslCon.
Definition: HttpClient.h:467
int getError()
Returns the last socket error code if any.
Definition: HttpClient.h:511
const char * getVal(HttpClient *c)
Returns the value.
Definition: HttpClient.h:522
int getStatus()
Returns the server's HTTP response code or a negative value on socket errors.
Definition: HttpClient.h:506
void setReadTmo(BaTime timeout)
Set the read timeout (in milliseconds).
Definition: HttpClient.h:449
const char * getKey(HttpClient *c)
Returns the key.
Definition: HttpClient.h:519
SharkSslConTrust trusted(void)
Returns the peer's "trust" status.
Definition: HttpClient.h:458
struct HttpClientKeyVal HttpClientKeyVal
A container for key/value pairs that is used when setting custom HTTP headers and/or when setting URL...
void setAcceptTrusted(bool acceptTrusted)
Force method HttpClient::request to accept only trusted connections when connecting to a server.
Definition: HttpClient.h:462
HttpClient(SoDisp *disp, U8 mode=HttpClient_Persistent)
Create a HttpClient instance.
Definition: HttpClient.h:437
HttpMethod
HTTP method types.
Definition: HttpServer.h:772
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:93
A dynamic buffer.
Definition: DynBuffer.h:60
A container for key/value pairs that is used when setting custom HTTP headers and/or when setting URL...
Definition: HttpClient.h:88
The HTTP(S) "C" client library implementation conforms to the HTTP/1.1 standard, RFC 2616.
Definition: HttpClient.h:190
Contains information about the physical socket connection.
Definition: SoDispCon.h:112
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:86