39#define BASLIB_VER "5671" 
   40#define BASLIB_VER_NO 5671 
   76#include "TargConfig.h" 
   77#include "HttpConnection.h" 
   78#include "DoubleList.h" 
   81#include "BaErrorCodes.h" 
   90#define BA_STACKSZ 24000 
   95#define BA_COOKIE_ID "z9ZAqJtI" 
  108struct HttpCmdThreadPoolIntf;
 
  136BA_API 
void httpFmtDate(
char* buf, U16 bufLen, 
BaTime t);
 
  141BA_API 
char* httpUnescape(
char* from);
 
  145BA_API 
char* httpEscape(
char* out, 
const char* in);
 
  151typedef void (*UserDefinedErrHandler)(BaFatalErrorCodes ecode1,
 
  190typedef int (*ZlibInflateInit2)(
struct z_stream_s* s, 
int  windowBits,
 
  191                     const char *version, 
int stream_size);
 
  193typedef int (*ZlibInflate)(
struct z_stream_s* s, 
int flush);
 
  194typedef int (*ZlibInflateEnd)(
struct z_stream_s* s);
 
  209typedef struct HttpHeader
 
  222BA_API 
const char* HttpHeader_name(HttpHeader* o, 
struct HttpRequest* req);
 
  223BA_API 
const char* HttpHeader_value(HttpHeader* o, 
struct HttpRequest* req);
 
  226inline const char* HttpHeader::name(
HttpRequest* req) {
 
  227   return HttpHeader_name(
this, req); }
 
  228inline const char* HttpHeader::value(
HttpRequest* req) {
 
  229   return HttpHeader_value(
this, req); }
 
  248   HttpInData_ParseHeader,
 
  250   HttpInData_ReadBodyAndParseUrlEncData
 
  251} HttpInData_ParseState;
 
  272      HttpAllocator allocator;
 
  281#define HttpAllocator_2Ptr(o, index) ((&(o)->buf[index])) 
  282#define HttpInData_lineStartPtr(o) \ 
  283  HttpAllocator_2Ptr(&(o)->allocator,(o)->lineStartI) 
  285#define HttpInData_getBufSize(o) \ 
  286  ((o)->lineStartI < (o)->allocator.index ? \ 
  287  (o)->allocator.index-(o)->lineStartI : 0) 
  289#define HttpInData_getBuf(o) HttpInData_lineStartPtr(o) 
  294   return HttpInData_getBuf(
this); }
 
  296   return HttpInData_getBufSize(
this); }
 
  388BA_API U32 HttpParameter_calculateSize(
struct HttpRequest* req);
 
  390BA_API 
const char* HttpParameter_getParameter(
 
  396   return HttpParameter_calculateSize(req); }
 
  398   return HttpParameter_clone(buf, req); }
 
  400   return HttpParameter_getParameter(
this, paramName); }
 
  469BA_API 
int HttpParameterIterator_constructor(
 
  474#define HttpParameterIterator_hasMoreElements(o) ((o)->name != 0) 
  475#define HttpParameterIterator_getName(o) (o)->name 
  476#define HttpParameterIterator_getValue(o) (o)->value 
  481inline HttpParameterIterator::HttpParameterIterator(
HttpRequest* req) {
 
  482   HttpParameterIterator_constructor(
this, req); }
 
  484   HttpParameterIterator_constructor2(
this, param); }
 
  486   HttpParameterIterator_nextElement(
this); }
 
  542      bool        getSecure()
  const { 
return secure ? true : 
false; }
 
  596      void setValue(
const char* newValue);
 
  600      int getVersion()
 const { 
return version; }
 
  602      void setVersion(
int v);
 
  624      BaBool  deleteCookieFlag;
 
  632BA_API 
void HttpCookie_destructor(
HttpCookie* o);
 
  633BA_API 
const char* HttpCookie_getComment(
HttpCookie* o);
 
  634BA_API 
const char* HttpCookie_getDomain(
HttpCookie* o);
 
  636BA_API 
const char* HttpCookie_getName(
HttpCookie* o);
 
  637BA_API 
const char* HttpCookie_getPath(
HttpCookie* o);
 
  638BA_API BaBool HttpCookie_getSecure(
HttpCookie* o);
 
  639BA_API BaBool HttpCookie_getHttpOnly(
HttpCookie* o);
 
  640BA_API 
const char* HttpCookie_getValue(
HttpCookie* o);
 
  641BA_API 
void HttpCookie_setComment(
HttpCookie* o, 
const char* purpose);
 
  642BA_API 
void HttpCookie_setDomain(
HttpCookie* o, 
const char* pattern);
 
  644#define HttpCookie_deleteCookie(o) (o)->deleteCookieFlag = TRUE; 
  645BA_API 
void HttpCookie_setPath(
HttpCookie* o, 
const char* uri);
 
  646BA_API 
void HttpCookie_setSecure(
HttpCookie* o, BaBool flag);
 
  647BA_API 
void HttpCookie_setHttpOnly(
HttpCookie* o, BaBool flag);
 
  648BA_API 
void HttpCookie_setValue(
HttpCookie* o, 
const char* newValue);
 
  652void HttpCookie_setVersion(
HttpCookie* o, 
int v);
 
  655BA_API 
void HttpCookie_activate(
HttpCookie* o);
 
  658inline HttpCookie::HttpCookie() { baAssert(0); }
 
  659inline HttpCookie::~HttpCookie() { HttpCookie_destructor(
this); }
 
  661   HttpCookie_setComment(
this, purpose); }
 
  663   HttpCookie_setDomain(
this, pattern); }
 
  665   HttpCookie_setMaxAge(
this, expiry); }
 
  667   HttpCookie_deleteCookie(
this); }
 
  669   HttpCookie_setPath(
this, uri); }
 
  671   HttpCookie_setSecure(
this, flag ? TRUE : FALSE); }
 
  673   HttpCookie_setHttpOnly(
this, flag ? TRUE : FALSE); }
 
  675   HttpCookie_setValue(
this, newValue); }
 
  677inline void HttpCookie::setVersion(
int v) {
 
  678   HttpCookie_setVersion(
this, v); }
 
  681   HttpCookie_activate(
this); }
 
  723      BaFileSize contentLength;
 
  726      U16 contentTypeHOffs;
 
  732BA_API 
const char* HttpStdHeaders_zzGetValFromOffs(
 
  735#define HttpStdHeaders_getConnection(o) \ 
  736  HttpStdHeaders_zzGetValFromOffs(o,(o)->connectionHOffs) 
  737#define HttpStdHeaders_getHost(o) \ 
  738  HttpStdHeaders_zzGetValFromOffs(o,(o)->hostHOffs) 
  739#define HttpStdHeaders_getContentType(o) \ 
  740  HttpStdHeaders_zzGetValFromOffs(o,(o)->contentTypeHOffs) 
  741#define HttpStdHeaders_getContentLength(o) (o)->contentLength 
  746   return  HttpStdHeaders_getConnection(
this); }
 
  748   return  HttpStdHeaders_getHost(
this); }
 
  750   return  HttpStdHeaders_getDomain(
this); }
 
  752   return  HttpStdHeaders_getContentType(
this); }
 
  754   return  HttpStdHeaders_getContentLength(
this); }
 
  773   HttpMethod_Connect   =0x00001,
 
  774   HttpMethod_Get       =0x00002,
 
  775   HttpMethod_Head      =0x00004,
 
  776   HttpMethod_Options   =0x00008,
 
  778   HttpMethod_Patch     =0x00010,
 
  779   HttpMethod_Post      =0x00020,
 
  780   HttpMethod_Put       =0x00040,
 
  781   HttpMethod_Trace     =0x00080,
 
  784   HttpMethod_Copy      =0x00100,
 
  785   HttpMethod_Delete    =0x00200,
 
  786   HttpMethod_Lock      =0x00400,
 
  787   HttpMethod_Move      =0x00800,
 
  789   HttpMethod_Mkcol     =0x01000,
 
  790   HttpMethod_Propfind  =0x02000,
 
  791   HttpMethod_Proppatch =0x04000,
 
  792   HttpMethod_Unlock    =0x08000,
 
  794   HttpMethod_Unknown   =0x10000 
 
  799BA_API 
HttpMethod HttpMethod_a2m(
const char* str);
 
 1011#ifndef NO_HTTP_SESSION 
 1034      int setUserObj(
void* userObj, 
bool overwrite=
false);
 
 1039      HttpAllocator headerAlloc;
 
 1040      HttpAllocator formAlloc;
 
 1052      BaBool postDataConsumed; 
 
 1059                                    U32 methods, BaBool addDefault);
 
 1060BA_API 
int HttpRequest_checkOptions(
 
 1062#define HttpRequest_getAuthenticatedUser(o) \ 
 1063  AuthenticatedUser_get2(HttpRequest_getSession(o,FALSE)) 
 1064#define HttpRequest_getConnection(o) HttpRequest_getCommand(o)->con 
 1065#define HttpRequest_getMethodType(o) (o)->methodType 
 1066#define HttpRequest_getMethod(o) HttpRequest_getMethod2((o)->methodType) 
 1067BA_API 
const char* HttpRequest_getMethod2(
HttpMethod method);
 
 1068#define HttpRequest_getServer(o) (o)->server 
 1069#define HttpRequest_getResponse(o) (&HttpRequest_getCommand(o)->response) 
 1071BA_API BaBool HttpRequest_checkTime(
 
 1073BA_API 
const char* HttpRequest_getRequestURI(
HttpRequest* o);
 
 1074BA_API 
const char* HttpRequest_getRequestURL(
HttpRequest* o,BaBool forceHttps);
 
 1075#define HttpRequest_getStdHeaders(o) (&(o)->stdH) 
 1076BA_API 
const char* HttpRequest_getVersion(
HttpRequest* o);
 
 1077BA_API 
const char* HttpRequest_getHeaderValue(
HttpRequest* o,
const char* name);
 
 1078#define HttpRequest_getNoOfParameters(o) (o)->formLen 
 1080#define HttpRequest_getUserObj(o) (o)->userObj 
 1081BA_API 
int HttpRequest_setUserObj(
 
 1083#define HttpRequest_getBuffer(o) (&(o)->inData) 
 1084BA_API 
const char* HttpRequest_getParameter(
 
 1086BA_API HttpHeader* HttpRequest_getHeaders(
HttpRequest* o, 
int* len);
 
 1088BA_API BaBool HttpRequest_enableKeepAlive(
HttpRequest* o);
 
 1089BA_API 
int HttpRequest_pushBackData(
HttpRequest* o);
 
 1090#ifndef NO_HTTP_SESSION 
 1094   HttpRequest* o, 
const char* val, 
size_t len, 
int set);
 
 1100                        U32 methods, 
bool addDefault){
 
 1101   return HttpRequest_checkMethods(
this,resp,
 
 1102      methods, addDefault ? TRUE : FALSE);}
 
 1105   return HttpRequest_checkTime(
this, resp, time); }
 
 1107   return HttpRequest_getAuthenticatedUser(
this); }
 
 1109   return HttpRequest_getMethodType(
this); }
 
 1111   return HttpRequest_getMethod(
this); }
 
 1113   return HttpRequest_getMethod2(method); }
 
 1115   return HttpRequest_getServer(
this); }
 
 1117   return HttpRequest_getRequestURI(
this); }
 
 1119   return HttpRequest_getRequestURL(
this, forceHttps); }
 
 1121   return HttpRequest_getStdHeaders(
this); }
 
 1123   return HttpRequest_getVersion(
this); }
 
 1125   return HttpRequest_getHeaderValue(
this, name); }
 
 1127   return HttpRequest_getCookie(
this, name); }
 
 1129   return HttpRequest_getParameter(
this, paramName); }
 
 1131   return HttpRequest_wsUpgrade(
this);
 
 1134   return HttpRequest_getHeaders(
this, len); }
 
 1135inline int HttpRequest::setUserObj(
void* userObj, 
bool overwrite) {
 
 1136   return HttpRequest_setUserObj(
this, userObj, overwrite); }
 
 1137inline void* HttpRequest::getUserObj() {
 
 1138   return HttpRequest_getUserObj(
this); }
 
 1139#ifndef NO_HTTP_SESSION 
 1141   return HttpRequest_getSession(
this, create); }
 
 1144   return HttpParameterIterator_hasMoreElements(
this); }
 
 1146   return HttpRequest_getBuffer(
this); }
 
 1155      U16 maxResponseHeader;
 
 1230      const char* 
encodeUrl(
const char* path);
 
 1263      int forward(
const char* path);
 
 1312      int include(
const char* path);
 
 1371      int sendError(
int eCode, 
const char* msg);
 
 1394      int fmtError(
int eCode, 
const char* fmt, ...);
 
 1473      int setHeader(
const char* name, 
const char* value, 
bool replace=
true);
 
 1515      char* 
fmtHeader(
const char* name, 
int valueLen, 
bool replace=
true);
 
 1537      int printf(
const char* fmt, ...);
 
 1555      int write(
const void* data, 
int len, 
int useBuffering=TRUE);
 
 1564      int write(
const char* data, 
int useBuffering=TRUE);
 
 1570      int send(
const void* data, 
int len);
 
 1607      int setUserObj(
void* userObj, 
bool overwrite=
false);
 
 1609      NameValMM nameValMM;
 
 1615      char* encodedRedirectURL;
 
 1620      HttpProtocol protocol;
 
 1624      char printAndWriteInitialized;
 
 1625      char useChunkTransfer;
 
 1633BA_API 
const char* HttpResponse_containsHeader(
 
 1635BA_API 
int HttpResponse_dataAdded(
HttpResponse* o, U32 size);
 
 1636#define HttpResponse_byteCount(o) ((o)->msgLen + (o)->bodyPrint->cursor) 
 1637BA_API 
const char* HttpResponse_encodeRedirectURL(
 
 1639BA_API 
const char* HttpResponse_encodeRedirectURLWithParamOrSessionURL(
 
 1641#define HttpResponse_encodeRedirectURLWithParam(o, path) \ 
 1642   HttpResponse_encodeRedirectURLWithParamOrSessionURL(o, path, FALSE) 
 1643#define HttpResponse_encodeSessionURL(o, path) \ 
 1644   HttpResponse_encodeRedirectURLWithParamOrSessionURL(o, path, TRUE) 
 1645BA_API 
const char* HttpResponse_encodeUrl(
HttpResponse* o, 
const char* path);
 
 1647#define HttpResponse_forward(o,path) HttpResponse_incOrForward(o,path,FALSE) 
 1648#define HttpResponse_getConnection(o) HttpResponse_getCommand(o)->con 
 1649#define HttpResponse_getRequest(o) (&HttpResponse_getCommand(o)->request) 
 1651#define HttpResponse_getBuf(o) (o)->bodyPrint->buf 
 1652#define HttpResponse_getBufSize(o) (o)->bodyPrint->bufSize 
 1653#define HttpResponse_getBufOffs(o) \ 
 1654   ((o)->bodyPrint->buf + (o)->bodyPrint->cursor) 
 1655#define HttpResponse_getRemBufSize(o) \ 
 1656   ((o)->bodyPrint->bufSize - (o)->bodyPrint->cursor) 
 1657#define HttpResponse_getUserObj(o) (o)->userObj 
 1658BA_API 
int HttpResponse_incOrForward(
 
 1660BA_API 
int HttpResponse_redirect(
HttpResponse* o, 
const char* path);
 
 1661#define HttpResponse_include(o,path) HttpResponse_incOrForward(o,path,TRUE) 
 1662#define HttpResponse_isChunkTransfer(o) (o)->useChunkTransfer 
 1663#define HttpResponse_committed(o) (o)->headerSent 
 1664#define HttpResponse_isForward(o) ((o)->forwardCounter != 0) 
 1665#define HttpResponse_isInclude(o) ((o)->includeCounter != 0) 
 1666#define HttpResponse_initial(o) (!HttpResponse_isForward(o) && \ 
 1667                                 !HttpResponse_isInclude(o)) 
 1668BA_API 
int HttpResponse_setResponseBuf(
 
 1670BA_API 
int HttpResponse_removeResponseBuf(
HttpResponse* o);
 
 1674BA_API 
int HttpResponse_sendError1(
HttpResponse* o, 
int eCode);
 
 1675BA_API 
int HttpResponse_sendError2(
HttpResponse* o,
int eCode,
const char* msg);
 
 1676BA_API 
int HttpResponse_sendBufAsError(
HttpResponse* o,
int eCode);
 
 1677BA_API 
int HttpResponse_sendBufAsTxtError(
HttpResponse* o,
int eCode);
 
 1678BA_API 
int HttpResponse_fmtVError(
 
 1683BA_API 
int HttpResponse_fmtError(
 
 1686   const char* fmt, ...);
 
 1687BA_API 
int HttpResponse_sendRedirect(
HttpResponse* o, 
const char* url);
 
 1688BA_API 
int HttpResponse_sendRedirectI(
 
 1691#define HttpResponse_forceHttps HttpResponse_redirect2TLS  
 1693#define HttpResponse_setBufPos(o, pos) (o)->bodyPrint->cursor = pos 
 1694BA_API 
int HttpResponse_setContentLength(
HttpResponse* o, BaFileSize len);
 
 1695BA_API 
int HttpResponse_setContentType(
HttpResponse* o, 
const char* type);
 
 1696BA_API 
int HttpResponse_checkContentType(
HttpResponse* o, 
const char* type);
 
 1697BA_API 
int HttpResponse_setDateHeader(
 
 1699BA_API 
int HttpResponse_setHeader(
 
 1700   HttpResponse* o,
const char* name,
const char* value, BaBool replace);
 
 1702BA_API 
char* HttpResponse_fmtHeader(
 
 1703   HttpResponse* o, 
const char* name, 
int valueLen, BaBool replace);
 
 1704BA_API 
int HttpResponse_setStatus(
HttpResponse* o, 
int eCode);
 
 1705BA_API 
int HttpResponse_vprintf(
 
 1707BA_API 
int HttpResponse_printf(
HttpResponse* o, 
const char* fmt, ...);
 
 1708BA_API 
int HttpResponse_write(
HttpResponse* o, 
const void* data, 
int len,
 
 1711BA_API 
int HttpResponse_send(
HttpResponse* o, 
const void* data, 
int len);
 
 1712BA_API 
int HttpResponse_setDefaultHeaders(
HttpResponse* o);
 
 1714BA_API 
int HttpResponse_setUserObj(
 
 1716BA_API 
int HttpResponse_printAndWriteInit(
HttpResponse* o);
 
 1717BA_API 
int HttpResponse_send100Continue(
HttpResponse* o);
 
 1718BA_API 
int HttpResponse_setChunkEncoding(
HttpResponse* o);
 
 1719BA_API 
const char* HttpResponse_getRespData(
HttpResponse* o, 
int* len);
 
 1720#define HttpResponse_getStatus(o) (o)->statusCode 
 1724   return HttpResponse_createCookie(
this, name); }
 
 1726   return HttpResponse_containsHeader(
this, name); }
 
 1728   return HttpResponse_byteCount(
this); }
 
 1730   return HttpResponse_encodeRedirectURL(
this, pathName); }
 
 1732   return HttpResponse_encodeRedirectURLWithParam(
this, p); }
 
 1734   return HttpResponse_encodeUrl(
this, path); }
 
 1736   return HttpResponse_flush(
this); }
 
 1738   return HttpResponse_forward(
this, path); }
 
 1740   return HttpResponse_redirect(
this, path); }
 
 1742   return HttpResponse_include(
this, path); }
 
 1744   return HttpResponse_committed(
this) ? true : 
false; }
 
 1746   return HttpResponse_isForward(
this) ? true : 
false; }
 
 1748   return HttpResponse_isInclude(
this) ? true : 
false; }
 
 1750   return HttpResponse_initial(
this) ? true : 
false; }
 
 1752   return HttpResponse_setResponseBuf(
this, buf, useDefBuffer?TRUE:FALSE); }
 
 1754   return HttpResponse_removeResponseBuf(
this); }
 
 1756   return HttpResponse_resetHeaders(
this); }
 
 1758   return HttpResponse_resetBuffer(
this); }
 
 1760   return HttpResponse_sendError1(
this, eCode); }
 
 1762   return HttpResponse_sendError2(
this, eCode, msg); }
 
 1764   return HttpResponse_sendBufAsError(
this, eCode); }
 
 1766   return HttpResponse_sendBufAsTxtError(
this,eCode);}
 
 1768   int retv; va_list varg;
 
 1769   va_start(varg, fmt);
 
 1770   retv = HttpResponse_fmtVError(
this, eCode, fmt, varg);
 
 1774   return HttpResponse_sendRedirect(
this, url); }
 
 1776   return HttpResponse_redirect2TLS(
this); }
 
 1778   return HttpResponse_setContentLength(
this, len); }
 
 1780   return HttpResponse_setContentType(
this, type); }
 
 1782   return HttpResponse_setDateHeader(
this, name, t); }
 
 1784   const char* name, 
const char* value, 
bool replace) {
 
 1785   return HttpResponse_setHeader(
this,name, value, replace?TRUE:FALSE); }
 
 1787   return HttpResponse_setMaxAge(
this, seconds); }
 
 1789   const char* name, 
int valueLen, 
bool replace) {
 
 1790   return HttpResponse_fmtHeader(
this, name, valueLen, replace?TRUE:FALSE); }
 
 1792   HttpResponse_setStatus(
this, eCode);}
 
 1795   int retv; va_list varg; va_start(varg, fmt);
 
 1796   retv = HttpResponse_vprintf(
this, fmt, varg); va_end(varg); 
return retv;}
 
 1798   return HttpResponse_write(
this, data, iStrlen(data), useBuffering); }
 
 1800   return HttpResponse_getWriter(
this); }
 
 1802   return HttpResponse_write(
this, data, len, useBuffering); }
 
 1804   return HttpResponse_send(
this, data, len); }
 
 1806   return HttpResponse_setDefaultHeaders(
this); }
 
 1807inline int HttpResponse::setUserObj(
void* userObj, 
bool overwrite) {
 
 1808   return HttpResponse_setUserObj(
this, userObj, overwrite); }
 
 1846      struct LHttpCommand* lcmd; 
 
 1848      BaBool runningInThread;
 
 1851#define HttpCommand_getRequest(o) (&(o)->request) 
 1852#define HttpCommand_getResponse(o) (&(o)->response) 
 1853#define HttpCommand_getConnection(o) (o)->con 
 1854#define HttpCommand_getServer(o) HttpConnection_getServer((o)->con) 
 1857   return HttpCommand_getRequest(
this); }
 
 1859   return HttpCommand_getResponse(
this); }
 
 1861   return HttpCommand_getConnection(
this); }
 
 1863   return HttpCommand_getServer(
this);
 
 1868#ifndef NO_HTTP_SESSION 
 1936BA_API 
void HttpSessionAttribute_constructor(
 
 1941#define HttpSessionAttribute_getSession(o) (o)->session 
 1947   HttpSessionAttribute_constructor(
this, name, d); }
 
 1949   return HttpSessionAttribute_getSession(
this); }
 
 1963      void operator delete(
void* d) { 
if(d) 
::baFree(d); }
 
 1964      void *
operator new(size_t, 
void *place) { 
return place; }
 
 1965      void operator delete(
void*, 
void *) { }
 
 2048      void incrementLock();
 
 2049      void decrementLock();
 
 2054      SplayTreeNode super; 
 
 2061      BaTime maxInactiveInterval;
 
 2082BA_API 
int HttpSession_removeAttribute(
HttpSession* o, 
const char* name);
 
 2083BA_API 
int HttpSession_setAttribute(
HttpSession* o,
 
 2086#define HttpSession_incrRefCntr(o) (o)->refCounter++ 
 2087BA_API 
void HttpSession_decrRefCntr(
HttpSession* o);
 
 2088#define HttpSession_incrementLock(o) (o)->lockCounter++ 
 2089#define HttpSession_decrementLock(o) do {\ 
 2090      baAssert((o)->lockCounter > 0);\ 
 2091      (o)->lockCounter--; } while(0) 
 2092BA_API 
int HttpSession_fmtSessionId(
HttpSession* o, U8* buf, 
size_t bufSize);
 
 2093#define HttpSession_getId(o) \ 
 2094   ((U32)((ptrdiff_t)SplayTreeNode_getKey((SplayTreeNode*)(o)))) 
 2095#define HttpSession_getAuthenticatedUser(o) AuthenticatedUser_get2((o)) 
 2096#define HttpSession_getUseCounter(o) (o)->useCounter 
 2097#define HttpSession_getPeerName(o) (&(o)->peer) 
 2101   return HttpSession_getAttribute(
this, name); }
 
 2103   return HttpSession_getCreationTime(
this); }
 
 2105   return HttpSession_getLastAccessedTime(
this); }
 
 2107   return HttpSession_getMaxInactiveInterval(
this); }
 
 2109   return HttpSession_getServer(
this); }
 
 2111   HttpSession_terminate(
this); }
 
 2113   return HttpSession_removeAttribute(
this, name); }
 
 2115   return HttpSession_setAttribute(
this, value); }
 
 2117   HttpSession_setMaxInactiveInterval(
this, interval); }
 
 2119   HttpSession_incrRefCntr(
this); }
 
 2121   HttpSession_decrRefCntr(
this); }
 
 2124   return HttpSession_getUseCounter(
this); }
 
 2126   return HttpSession_getAuthenticatedUser(
this); }
 
 2127inline void HttpSession::incrementLock() {HttpSession_incrementLock(
this);}
 
 2128inline void HttpSession::decrementLock() {HttpSession_decrementLock(
this);}
 
 2133   HttpSessionContainer_OK = 0,
 
 2134   HttpSessionContainer_NoMemory,
 
 2135   HttpSessionContainer_TooManySessions,
 
 2136   HttpSessionContainer_NoPeerAddress
 
 2137} HttpSessionContainer_ECode;
 
 2155      SplayTree sessionTree;
 
 2156      DoubleList sessionList;
 
 2157      DoubleList sessionTermList;
 
 2158      DoubleLink* sessionLinkIter;
 
 2162      HttpSessionContainer_ECode eCode;
 
 2173#define HttpSessionContainer_setMaxSessions(o,max) (o)->maxSessions = max 
 2177   HttpSessionContainer_setMaxSessions(
this, max); }
 
 2195#define HttpPageType_HttpPageSE                0x00020 
 2198typedef struct HttpPageNode
 
 2200      struct HttpPageNode* next;
 
 2259      void operator delete(
void* d) { 
if(d) 
::baFree(d); }
 
 2260      void *
operator new(size_t, 
void *place) { 
return place; }
 
 2261      void operator delete(
void*, 
void *) { }
 
 2305BA_API HttpPage_constructor(
 
 2307BA_API 
void HttpPage_destructor(
HttpPage* o);
 
 2308#define HttpPage_getName(o) (o)->name 
 2309#define HttpPage_isLinked(o) ((HttpPageNode*)(o))->next 
 2310BA_API 
int HttpPage_unlink(
HttpPage* o);
 
 2311#define HttpPage_service(o, request, response) \ 
 2312  (o)->serviceCB(o, request, response) 
 2316   HttpPage_constructor(
this, 
service, name); }
 
 2318   HttpPage_destructor(
this); }
 
 2320   return HttpPage_isLinked(
this) ? true : 
false;
 
 2324   HttpPage_service(
this, request, response);
 
 2335                               const char* relPath,
 
 2338#define HttpDirType_EhDir                    0x00001 
 2339#define HttpDirType_HttpResRdr               0x00002 
 2340#define HttpDirType_AuthenticateDir          0x00008 
 2341#define HttpDirType_AuthenticateDirWrapper   0x00010 
 2367      void operator delete(
void* d) { 
if(d) 
::baFree(d); }
 
 2368      void *
operator new(size_t, 
void *place) { 
return place; }
 
 2369      void operator delete(
void*, 
void *) { }
 
 2389      HttpDir(
const char* name, S8 priority=0);
 
 2445                              unsigned int nameLen);
 
 2485      char* 
makeAbsPath(
const char* relPath, 
int relPathLen);
 
 2566      HttpPageNode pageList;     
 
 2574BA_API 
void HttpDir_constructor(
HttpDir* o, 
const char* name, S8 priority);
 
 2575BA_API 
void HttpDir_destructor(
HttpDir* o);
 
 2576BA_API 
char* HttpDir_makeAbsPath(
 
 2577   HttpDir* o, 
const char* relPath, 
int relPathLen);
 
 2578#define HttpDir_getRootPath(o) HttpDir_makeAbsPath(o,"",0)
 
 2580#define HttpDir_getFirstPage(o) \ 
 2581   (o)->pageList.next != &(o)->pageList ? ((HttpPage*)(o)->pageList.next) : 0 
 2582#define HttpDir_getFirstDir(o) (o)->dirList 
 2585#define HttpDir_getNext(o) (o)->next 
 2586#define HttpDir_getName(o) (o)->name 
 2587#define HttpDir_getParent(o) (o)->parent 
 2591BA_API 
HttpDir* HttpDir_findDir(
 
 2592   HttpDir* iter, 
const char* name,
unsigned int nameLen);
 
 2593BA_API 
HttpDir* HttpDir_createOrGet(
HttpDir* o, 
const char* name);
 
 2594BA_API 
void HttpDir_p403(
HttpDir* o, 
const char* p403);
 
 2595#define HttpDir_overloadService HttpDir_setService 
 2597#define HttpDir_isLinked(o) (o)->parent 
 2598BA_API 
int HttpDir_unlink(
HttpDir* o);
 
 2599#define HttpDir_setAuthenticator(o,authenticatorMA,authorizerMA) \ 
 2600   (o)->authenticator = authenticatorMA,(o)->realm = authorizerMA 
 2601BA_API 
int HttpDir_authenticateAndAuthorize(
 
 2603#define HttpDir_isAuthorized(o,user,method,path) \ 
 2605  (user ? AuthorizerIntf_authorize((o)->realm,user,method,path) : FALSE) : \ 
 2610   HttpDir_constructor(
this, 0, 0); }
 
 2612   HttpDir_constructor(
this, name, priority); }
 
 2613inline HttpDir::~HttpDir() {
 
 2614   HttpDir_destructor(
this); }
 
 2616   return HttpDir_makeAbsPath(
this, relPath, relPathLen); }
 
 2618   return HttpDir_getRootPath(
this); }
 
 2620   return HttpDir_insertDir(
this, dir); }
 
 2622   return HttpDir_insertPage(
this, page); }
 
 2626   return HttpDir_getDir(
this,name); }
 
 2628   return HttpDir_getPage(
this,name); }
 
 2631   return HttpDir_findPage(
this, iter, name); }
 
 2633                                        unsigned int nameLen) {
 
 2634   return HttpDir_findDir(iter, name, nameLen); }
 
 2636   return HttpDir_createOrGet(
this, name); }
 
 2638   return HttpDir_setService(
this, s); }
 
 2640   HttpDir_p403(
this, 
p403); }
 
 2643   return HttpDir_isLinked(
this) ? true : 
false; }
 
 2646   HttpDir_setAuthenticator(
this,authenticator,authorizer);
 
 2650   return HttpDir_authenticateAndAuthorize(
this,cmd,path) ? true : 
false; }
 
 2655typedef struct HttpLinkCon
 
 2667      BaBool page404InProgress;
 
 2809      U16 minResponseHeader;
 
 2810      U16 maxResponseHeader;
 
 2813      U16 noOfHttpCommands;
 
 2814      U16 noOfHttpConnections;
 
 2822BA_API 
int HttpServerConfig_setRequest(
HttpServerConfig* o, S16 min, S16 max);
 
 2823BA_API 
int HttpServerConfig_setResponseHeader(
 
 2827BA_API 
int HttpServerConfig_setNoOfHttpCommands(
HttpServerConfig* o, U16 size);
 
 2828BA_API 
int HttpServerConfig_setNoOfHttpConnections(
 
 2834   HttpServerConfig_constructor(
this); }
 
 2836   return HttpServerConfig_setRequest(
this, min, max); }
 
 2838   return HttpServerConfig_setResponseHeader(
this, min, max); }
 
 2840   return HttpServerConfig_setResponseData(
this, size); }
 
 2842   return HttpServerConfig_setCommit(
this, size); }
 
 2844   return HttpServerConfig_setNoOfHttpCommands(
this, size); }
 
 2846   return HttpServerConfig_setNoOfHttpConnections(
this, size); }
 
 2848   return HttpServerConfig_setMaxSessions(
this, size); }
 
 2853typedef DoubleList HttpLinkConList;
 
 2856typedef void (*LspOnTerminateRequest)(
struct LHttpCommand* lcmd);
 
 2864      void operator delete(
void* d) { 
if(d) 
::baFree(d); }
 
 2865      void *
operator new(size_t, 
void *place) { 
return place; }
 
 2866      void operator delete(
void*, 
void *) { }
 
 2953                    const char* virtualDirRootPath,
 
 2956      struct AuthUserList* getAuthUserList(
const char* name);
 
 2974#ifndef NO_HTTP_SESSION 
 3000      int setUserObj(
void* userObj, 
bool overwrite=
false);
 
 3019      static void setErrHnd(UserDefinedErrHandler e);
 
 3022      static int setZlib(ZlibInflateInit2 init,
 
 3023                         ZlibInflate inflate,
 
 3024                         ZlibInflateEnd end){
 
 3025                            (void)init; (void)inflate; (void)end;
 
 3033      DoubleList commandPool;
 
 3034      DoubleList cmdReqList;
 
 3036      HttpLinkConList freeList;
 
 3037      HttpLinkConList readyList;
 
 3038      HttpLinkConList connectedList;
 
 3039      HttpRootDir rootDirContainer;
 
 3040      SplayTree authUserTree; 
 
 3041      struct HttpCmdThreadPoolIntf* threadPoolIntf;
 
 3042      HttpLinkCon* connections;
 
 3045      void* waitForConClose; 
 
 3046      LspOnTerminateRequest lspOnTerminateRequest;
 
 3047      int commandPoolSize;
 
 3048      U16 noOfConnections;
 
 3049      S16 maxHttpRequestLen;
 
 3050#ifndef NO_HTTP_SESSION 
 3057void HttpServer_AsynchProcessDir(
HttpServer* o,
 
 3061#define HttpServer_setThreadPoolIntf(o, intf) (o)->threadPoolIntf=intf 
 3062#define HttpServer_luaenv(o) (o)->luaenv 
 3068BA_API 
void HttpServer_destructor(
HttpServer* o);
 
 3070BA_API 
int HttpServer_insertDir(
HttpServer* o,
 
 3071                                const char* virtualDirRootPath,
 
 3073BA_API 
int HttpServer_insertCSP(
HttpServer* o,
 
 3075                                const char* virtualDirRootPath,
 
 3077#define HttpServer_getAuthUserList(o, name) \ 
 3078   (AuthUserList*)SplayTree_find(&(o)->authUserTree, name) 
 3079#define HttpServer_getDispatcher(o) (o)->dispatcher 
 3080#define HttpServer_getFirstRootDir(o) \ 
 3081     HttpDir_getFirstDir((HttpDir*)&(o)->rootDirContainer) 
 3082#define HttpServer_getUserObj(o) (o)->userObj 
 3083#define HttpServer_getSessionContainer(o) (&(o)->sessionContainer) 
 3084#define HttpServer_getMutex(o) SoDisp_getMutex((o)->dispatcher) 
 3085BA_API 
const char* HttpServer_getStatusCode(
int code);
 
 3087void HttpServer_doLingeringClose(
 
 3090#ifndef NO_HTTP_SESSION 
 3096BA_API 
void HttpServer_setErrHnd(UserDefinedErrHandler e);
 
 3097void HttpServer_initStatic(
void);
 
 3098int HttpServer_termOldestIdleCon(
HttpServer* o);
 
 3099BA_API 
void HttpServer_set404Page(
HttpServer*o, 
const char* page404);
 
 3100#define HttpServer_get404Page(o) (o)->rootDirContainer.page404 
 3101BA_API 
int HttpServer_setUserObj(
 
 3102   HttpServer* o, 
void* userObj, BaBool overwrite);
 
 3103#define HttpServer_termAllSessions(o) \ 
 3104   HttpSessionContainer_destructor(&(o)->sessionContainer) 
 3106#define HttpServer_setZlib(init,inflate,end); 
 3110   HttpServer_constructor(
this, disp, cfg); }
 
 3111inline HttpServer::~HttpServer()  {
 
 3112   HttpServer_destructor(
this); }
 
 3114   return HttpServer_insertRootDir(
this, dir); }
 
 3116   return HttpServer_getMutex(
this);
 
 3119   return HttpServer_insertDir(
this, virtualDirRootPath, dir); }
 
 3121                                 const char* virtualDirRootPath,
 
 3123   return HttpServer_insertCSP(
this, cspInit, virtualDirRootPath, reader); }
 
 3124inline struct AuthUserList* HttpServer::getAuthUserList(
const char* name) {
 
 3125   return HttpServer_getAuthUserList(
this,name); }
 
 3127   return HttpServer_getDispatcher(
this); }
 
 3129   return HttpServer_getFirstRootDir(
this); }
 
 3131   return HttpServer_getSessionContainer(
this); }
 
 3132#ifndef NO_HTTP_SESSION 
 3134   return HttpServer_getSession(
this, 
id); }
 
 3136   HttpServer_initStatic(); }
 
 3138   HttpServer_setErrHnd(e); }
 
 3140   HttpServer_set404Page(
this, page404); }
 
 3142   return HttpServer_get404Page(
this); }
 
 3143inline int HttpServer::setUserObj(
void* userObj, 
bool overwrite) {
 
 3144   return HttpServer_setUserObj(
this, userObj, overwrite); }
 
 3146   return HttpServer_getStatusCode(code);
 
 3152   return HttpRequest_getResponse(
this); }
 
 3154   return HttpRequest_getConnection(
this); }
 
 3156   return HttpResponse_getRequest(
this); }
 
 3158   return HttpResponse_getCommand(
this); }
 
 3160   return HttpRequest_getCommand(
this); }
 
 3162   return HttpConnection_getServer(
this); }
 
 3171#define SHARKSSL_MD5_HASH_LEN       16 
 3172#define SHARKSSL_SHA1_HASH_LEN      20 
 3174typedef struct SharkSslMd5Ctx
 
 3181SHARKSSL_API 
void  SharkSslMd5Ctx_constructor(SharkSslMd5Ctx* ctx);
 
 3182SHARKSSL_API 
void  SharkSslMd5Ctx_append(SharkSslMd5Ctx* ctx, 
const U8* data, U32 len);
 
 3183SHARKSSL_API 
void  SharkSslMd5Ctx_finish(SharkSslMd5Ctx* ctx, U8 digest[]);
 
 3184SHARKSSL_API 
int   sharkssl_md5(
const U8*, U16, U8*); 
 
 3186typedef struct SharkSslSha1Ctx
 
 3193SHARKSSL_API 
void  SharkSslSha1Ctx_constructor(SharkSslSha1Ctx* ctx);
 
 3194SHARKSSL_API 
void  SharkSslSha1Ctx_append(SharkSslSha1Ctx* ctx, 
const U8* data, U32 len);
 
 3195SHARKSSL_API 
void  SharkSslSha1Ctx_finish(SharkSslSha1Ctx*, U8 digest[]);
 
 3197typedef void SharkSsl;
 
void(* CspInit)(struct HttpDir *cspRoot, struct CspReader *reader)
Function prototype for the "initialize function" generated by CspLink.
Definition: HttpServer.h:182
 
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
 
void baFree(void *p)
Deallocates space to which it points.
 
BaTime getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of second...
Definition: HttpServer.h:2104
 
void deleteCookie()
Specifies a path for the cookie to which the client should return the cookie.
Definition: HttpServer.h:666
 
HttpHeader * getHeaders(int *len)
Return a HTTP header iterator that can iterate and fetch all the HTTP headers.
Definition: HttpServer.h:1133
 
int include(const char *path)
Includes the content of a resource (servlet, CSP page, HTML file) in the response.
Definition: HttpServer.h:1741
 
BaTime getCreationTime()
Returns the time when this session was created, measured in seconds since midnight January 1,...
Definition: HttpServer.h:2102
 
int setMaxAge(BaTime seconds)
Sets header "Cache-Control: max-age=seconds".
Definition: HttpServer.h:1786
 
int setDateHeader(const char *name, BaTime time)
Sets a response header with the given name and date-value.
Definition: HttpServer.h:1781
 
HttpDir * getNext()
Returns the next dir in the parent list.
Definition: HttpServer.h:2629
 
const char * getRequestURI()
Returns the pathname.
Definition: HttpServer.h:1116
 
const char * containsHeader(const char *name)
Searches the internal response header database for a header with the specified name.
Definition: HttpServer.h:1725
 
const char * getContentType()
Returns the content type, for example: "application/x-www-form-urlencoded".
Definition: HttpServer.h:751
 
const char * getHost()
Returns the host header.
Definition: HttpServer.h:747
 
int flush()
Forces any content in the buffer to be written to the client.
Definition: HttpServer.h:1735
 
void(* HttpSessionAttribute_Destructor)(struct HttpSessionAttribute *o)
HttpSessionAttribute termination callback function.
Definition: HttpServer.h:1881
 
int sendError(int eCode)
Sends an error response as a simple HTML page to the client using the specified status code.
Definition: HttpServer.h:1759
 
int forward(const char *path)
Forwards a request from a servlet to another resource (servlet, CSP file, or HTML file).
Definition: HttpServer.h:1737
 
void setHttpOnly(bool flag)
Marks or unmarks this Cookie as HttpOnly.
Definition: HttpServer.h:672
 
int setContentLength(BaFileSize len)
Sets the "Content-Length" parameter value.
Definition: HttpServer.h:1777
 
void setSecure(bool flag)
Inform the browser whether the cookie should be sent only using a secure protocol such as HTTPS – i....
Definition: HttpServer.h:670
 
HttpPage * findPage(HttpPage *iter, const char *name)
Searches for a page in this directory node.
Definition: HttpServer.h:2630
 
HttpServer * getServer()
Returns the web server object.
Definition: HttpServer.h:1114
 
int resetHeaders()
Removes all HTTP headers.
Definition: HttpServer.h:1755
 
struct HttpServer * getServer()
Get the web-server object.
Definition: HttpServer.h:1862
 
HttpRequest * getRequest()
Get the request object.
Definition: HttpServer.h:1856
 
int insertPage(HttpPage *page)
Insert a page in the directory.
Definition: HttpServer.h:2621
 
int setAttribute(HttpSessionAttribute *value)
Binds an object to this session, using the name specified.
Definition: HttpServer.h:2114
 
HttpMethod getMethodType()
Returns the method type.
Definition: HttpServer.h:1108
 
int send(const void *data, int len)
Used when sending raw data to the client.
Definition: HttpServer.h:1803
 
HttpResponse * getResponse()
Get the response object.
Definition: HttpServer.h:1858
 
int removeResponseBuf()
Remove buffer set by using setResponseBuf.
Definition: HttpServer.h:1753
 
HttpMethod
HTTP method types.
Definition: HttpServer.h:772
 
HttpConnection * getConnection()
Returns the connection object associated with this request.
Definition: HttpServer.h:3153
 
const char * getDomain()
Returns the host header without any port number.
Definition: HttpServer.h:749
 
struct HttpRequest HttpRequest
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
 
void setAuthenticator(struct AuthenticatorIntf *authenticator, struct AuthorizerIntf *authorizer=0)
Set the optional authenticator and/or the optional AuthorizerIntf.
Definition: HttpServer.h:2644
 
struct HttpConnection * getConnection()
Get the current connection object that the HttpCommand instance is bound with.
Definition: HttpServer.h:1860
 
int sendBufAsTxtError(int eCode)
Sends the data formatted into the HttpResponse buffer as an error message to the client.
Definition: HttpServer.h:1765
 
bool isForward() const
Returns true if this is a forward request from another servlet or CSP file.
Definition: HttpServer.h:1745
 
AuthenticatedUser * getAuthenticatedUser()
Returns the authenticated user or NULL if user is not authenticated.
Definition: HttpServer.h:1106
 
int unlink()
Unlinks/removes the page from the parent directory.
Definition: HttpServer.h:2322
 
HttpServer * getServer()
Get the server object.
Definition: HttpServer.h:2108
 
struct HttpSessionAttribute HttpSessionAttribute
The interface to an HttpSession attribute.
 
int setRequest(S16 min, S16 max)
Set the size of the HTTP request buffer.
Definition: HttpServer.h:2835
 
bool hasMoreElements()
Returns true if more elements.
Definition: HttpServer.h:1143
 
HttpStdHeaders * getStdHeaders()
Returns an object containing standard HTTP headers.
Definition: HttpServer.h:1120
 
const char * getHeaderValue(const char *name)
Returns the value of the specified request header.
Definition: HttpServer.h:1124
 
int setDefaultHeaders()
Sets the most common header values in servlet and CSP files.
Definition: HttpServer.h:1805
 
int resetBuffer()
Clears the content of the underlying buffer in the response without clearing headers or status code.
Definition: HttpServer.h:1757
 
int insertCSP(CspInit cspInit, const char *virtualDirRootPath, struct CspReader *reader)
Insert and initialize a CSP Virtual Directory.
Definition: HttpServer.h:3120
 
struct HttpServerConfig HttpServerConfig
Use an instance of this class if you want to override the default web-server parameters.
 
const char * encodeRedirectURL(const char *pathName)
Encodes the specified URL into an absolute URL, or if encoding is not needed, returns the URL unchang...
Definition: HttpServer.h:1729
 
bool initial() const
Returns true if this is the initial page.
Definition: HttpServer.h:1749
 
struct HttpStdHeaders HttpStdHeaders
Standard HTTP header values.
 
static void setErrHnd(UserDefinedErrHandler e)
You can set your own user defined error handler for the web-server.
Definition: HttpServer.h:3137
 
void terminate()
Unbinds any objects bound to this session object, runs the HttpSession destructor,...
Definition: HttpServer.h:2110
 
struct HttpResponse HttpResponse
This object is used when sending response messages back to the client.
 
~HttpPage()
The HttpPage destructor unlinks the page from the parent directory.
Definition: HttpServer.h:2317
 
void nextElement()
Advance to the next element.
Definition: HttpServer.h:485
 
SBaFileSize getContentLength()
Returns the content length if request contains a body.
Definition: HttpServer.h:753
 
U32 byteCount()
Returns number of bytes sent thus far.
Definition: HttpServer.h:1727
 
int setCommit(U16 size)
Set the size of the HTTP response commit buffer.
Definition: HttpServer.h:2841
 
HttpDir()
Constructor for creating a root dir, a root dir has no name.
Definition: HttpServer.h:2609
 
struct HttpServer HttpServer
The Web Server.
 
HttpCookie * getCookie(const char *name)
Returns the requested cookie or NULL if no cookie matches the name.
Definition: HttpServer.h:1126
 
ThreadMutex * getMutex()
Get the dispatcher mutex.
Definition: HttpServer.h:3115
 
void service(HttpRequest *request, HttpResponse *response)
The virtual service function (C callback function) is normally run by the parent directory when deleg...
Definition: HttpServer.h:2323
 
void setMaxAge(BaTime expiry)
Sets the maximum age of the cookie in seconds.
Definition: HttpServer.h:664
 
int setResponseBuf(BufPrint *buf, bool useDefBuffer=true)
This is an advanced function that makes it possible to redirect the output, which is normally sent to...
Definition: HttpServer.h:1751
 
HttpSessionContainer * getSessionContainer()
Get the HttpSessionContainer.
Definition: HttpServer.h:3130
 
HttpDir * getFirstRootDir()
Returns the first root directory.
Definition: HttpServer.h:3128
 
HttpSessionAttribute * getAttribute(const char *name)
Returns the object bound with the specified name in this session, or null if no object is bound under...
Definition: HttpServer.h:2100
 
AuthenticatedUser * getAuthenticatedUser()
Returns the AuthenticatedUser if user is authenticated.
Definition: HttpServer.h:2125
 
int setContentType(const char *type)
Sets the "Content-Type" parameter value.
Definition: HttpServer.h:1779
 
void(* HttpPage_Service)(struct HttpPage *page, HttpRequest *request, HttpResponse *response)
The HttpPage service function.
Definition: HttpServer.h:2190
 
struct HttpCookie HttpCookie
A cookie is used for exchanging a small amount of information between a HttpPage and a web browser.
 
U32 getId()
Returns a unique identifier assigned to this session.
Definition: HttpServer.h:2122
 
int setResponseHeader(U16 min, U16 max)
Set the size of the HTTP response header buffer.
Definition: HttpServer.h:2837
 
void set404Page(const char *page404)
Set a more user friendly 404 page.
Definition: HttpServer.h:3139
 
const char * encodeRedirectURLWithParam(const char *pathName)
This method is similar to HttpResponse::encodeRedirectURL, but this method also includes all URL-enco...
Definition: HttpServer.h:1731
 
static void initStatic(void)
The only purpose with this function is to clean all static variables that are in the BSS section; i....
Definition: HttpServer.h:3135
 
struct HttpServer * getServer()
Fetch the HttpServer object.
Definition: HttpServer.h:3161
 
BufPrint * getWriter()
Returns a BufPrint object that can send any type of data to the client.
Definition: HttpServer.h:1799
 
int write(const void *data, int len, int useBuffering=TRUE)
Used for sending pre-formatted data to the client.
Definition: HttpServer.h:1801
 
int setMaxSessions(U16 size)
Maximum allowed active HttpSession objects.
Definition: HttpServer.h:2847
 
HttpInData * getBuffer()
Get the internal rec buffer.
Definition: HttpServer.h:1145
 
const char * encodeUrl(const char *path)
Encodes an absolute or relative URL, or if encoding is not needed, returns the URL unchanged.
Definition: HttpServer.h:1733
 
int setNoOfHttpCommands(U16 size)
The number of HttpCommand instances created by the web-server.
Definition: HttpServer.h:2843
 
HttpDir * createOrGet(const char *name)
Returns a sub-directory with the given name.
Definition: HttpServer.h:2635
 
bool authenticateAndAuthorize(HttpCommand *cmd, const char *path)
Authenticate and authorize the user.
Definition: HttpServer.h:2648
 
int(* HttpDir_Service)(struct HttpDir *o, const char *relPath, HttpCommand *cmd)
The HttpDir service callback function.
Definition: HttpServer.h:2334
 
HttpServer(SoDisp *dispatcher, HttpServerConfig *cfg=0)
Create a Web Server object.
Definition: HttpServer.h:3109
 
struct HttpCommand HttpCommand
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
 
char * fmtHeader(const char *name, int valueLen, bool replace=true)
Pre-allocate memory for a {name, value} pair in the response header database.
Definition: HttpServer.h:1788
 
bool isInclude() const
Returns true if this is an include from another servlet or CSP file.
Definition: HttpServer.h:1747
 
int unlink()
Unlinks/removes the directory from the parent directory.
Definition: HttpServer.h:2641
 
char * getRootPath()
Calculates the root of where the HttpDir instance is installed in the virtual file system.
Definition: HttpServer.h:2617
 
int checkMethods(HttpResponse *resp, U32 methods, bool addDefault=TRUE)
Checks the HTTP method type and sends a response message if condition met.
Definition: HttpServer.h:1099
 
const char * getVersion()
Returns the HTTP version as a string, normally "1.1".
Definition: HttpServer.h:1122
 
int printf(const char *fmt,...)
printf is used for sending formatted data to the client.
Definition: HttpServer.h:1794
 
int redirect2TLS()
Converts the URL to HTTPS and sends a redirect (301) response to the client if this is a non secure c...
Definition: HttpServer.h:1775
 
HttpPage * getFirstPage()
Returns the first page.
Definition: HttpServer.h:2623
 
SoDisp * getDispatcher()
Returns the dispatcher object.
Definition: HttpServer.h:3126
 
HttpDir * getDir(const char *name)
Returns the first directory with the name given or NULL if not found.
Definition: HttpServer.h:2625
 
int wsUpgrade()
Activate a WebSocket handshake.
Definition: HttpServer.h:1130
 
void setPath(const char *uri)
Set the cookie path.
Definition: HttpServer.h:668
 
static const char * getStatusCode(int code)
Return a short description for common HTTP error codes.
Definition: HttpServer.h:3145
 
char * makeAbsPath(const char *relPath, int relPathLen)
Makes an absolute path based on where the HttpDir instance is installed in the virtual file system an...
Definition: HttpServer.h:2615
 
struct HttpSessionContainer HttpSessionContainer
The HttpSession container class.
 
HttpSession * getSession(U32 id)
Returns the HttpSession associated with id or NULL if not found.
Definition: HttpServer.h:3133
 
U32 getUseCounter()
Get the session usage counter.
Definition: HttpServer.h:2123
 
bool committed() const
Returns a boolean indicating if the response has been committed.
Definition: HttpServer.h:1743
 
int redirect(const char *path)
Internally redirects the request to another resource.
Definition: HttpServer.h:1739
 
void incrRefCntr()
Increments the session reference counter.
Definition: HttpServer.h:2118
 
const char * getConnection()
Returns the connection type for HTTP 1.1 connections, returns "Close" or "Keep-Alive.
Definition: HttpServer.h:745
 
const char * getParameter(const char *paramName)
Returns the value of a request parameter as a const char* or null if the parameter does not exist.
Definition: HttpServer.h:1128
 
void decrRefCntr()
Decrements the session reference counter.
Definition: HttpServer.h:2120
 
const char * getRequestURL(bool forceHttps=false)
Reconstructs the URL the client used to make the request.
Definition: HttpServer.h:1118
 
HttpCommand * getCommand()
Get the HttpCommand object.
Definition: HttpServer.h:3159
 
int insertDir(HttpDir *dir)
Insert a sub-directory.
Definition: HttpServer.h:2619
 
void setMaxInactiveInterval(BaTime interval)
Specifies the time, in seconds, between client requests before the session container will invalidate ...
Definition: HttpServer.h:2116
 
void setMaxSessions(int max)
Set the maximum number of session objects.
Definition: HttpServer.h:2176
 
struct HttpSession HttpSession
Provides a way to identify a user across more than one page request or visit to a web site,...
 
bool isLinked()
Returns true if this page node is installed into a parent directory.
Definition: HttpServer.h:2319
 
const char * get404Page()
Returns a pointer to the current 404 page, if any.
Definition: HttpServer.h:3141
 
HttpCommand * getCommand()
Get the HttpCommand object.
Definition: HttpServer.h:3157
 
static HttpDir * findDir(HttpDir *iter, const char *name, unsigned int nameLen)
Searches for a sub-directory in this directory node.
Definition: HttpServer.h:2632
 
HttpSession * getSession(BaBool create=true)
Returns the current HttpSession associated with this request, or if there is no current session and c...
Definition: HttpServer.h:1140
 
HttpServerConfig()
The constructor sets up the default parameters.
Definition: HttpServer.h:2833
 
const char * getMethod()
Returns a string representation of the value returned by HttpRequest::getMethodType.
Definition: HttpServer.h:1110
 
void setValue(const char *newValue)
Assigns a new value to a cookie after the cookie is created.
Definition: HttpServer.h:674
 
BaTime getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the session container will keep this session open...
Definition: HttpServer.h:2106
 
HttpCookie * createCookie(const char *name)
Create a cookie.
Definition: HttpServer.h:1723
 
HttpPage * getPage(const char *name)
Returns the page with the name given or NULL if not found.
Definition: HttpServer.h:2627
 
int fmtError(int eCode, const char *fmt,...)
This method implements a printf like implementation for formatting and sending an error message.
Definition: HttpServer.h:1767
 
struct HttpPage HttpPage
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
 
HttpDir_Service setService(HttpDir_Service s)
Replace the original service function in HttpDir with your own.
Definition: HttpServer.h:2637
 
HttpDir * getFirstDir()
Returns the first sub-directory.
Definition: HttpServer.h:2624
 
bool isLinked()
Returns true if this directory node is installed into a parent directory.
Definition: HttpServer.h:2642
 
HttpResponse * getResponse()
Returns the HttpResponse object.
Definition: HttpServer.h:3151
 
int insertDir(const char *virtualDirRootPath, HttpDir *dir)
Insert a directory node into the virtual file system.
Definition: HttpServer.h:3118
 
void setStatus(int statusCode)
Sets the status code for this response.
Definition: HttpServer.h:1791
 
int insertRootDir(HttpDir *dir)
Insert a root directory node.
Definition: HttpServer.h:3113
 
int setHeader(const char *name, const char *value, bool replace=true)
Sets a HTTP response header with the given name and value.
Definition: HttpServer.h:1783
 
HttpRequest * getRequest()
Get the HttpRequest object.
Definition: HttpServer.h:3155
 
void p403(const char *p403)
Set a 403 denied request handler.
Definition: HttpServer.h:2639
 
HttpSession * getSession()
Get the session object.
Definition: HttpServer.h:1948
 
BaBool checkTime(struct HttpResponse *resp, BaTime time)
Parses and checks if the "If-Modified-Since" time is equal or greater than "time".
Definition: HttpServer.h:1104
 
void activate()
Activates the cookie.
Definition: HttpServer.h:680
 
int sendRedirect(const char *url)
Sends a temporary redirect (302) response to the client using the specified redirect location URL.
Definition: HttpServer.h:1773
 
int setResponseData(U16 size)
The HttpResponse object stores formatted data in the response data buffer.
Definition: HttpServer.h:2839
 
int removeAttribute(const char *name)
Removes the object bound with the specified name from this session.
Definition: HttpServer.h:2112
 
void setDomain(const char *pattern)
Specifies the domain within which this cookie should be presented.
Definition: HttpServer.h:662
 
int setNoOfHttpConnections(U16 size)
Number of HttpConnection instances.
Definition: HttpServer.h:2845
 
void setComment(const char *purpose)
Specifies a comment that describes a cookie's purpose.
Definition: HttpServer.h:660
 
int sendBufAsError(int eCode)
Sends the data formatted into the HttpResponse buffer as an error message to the client.
Definition: HttpServer.h:1763
 
HttpSessionAttribute(const char *name, HttpSessionAttribute_Destructor terminate)
Create a session attribute.
Definition: HttpServer.h:1944
 
struct HttpDir HttpDir
An instance of the HttpDir class, which is a collection of zero or more resources,...
 
struct HttpParameterIterator HttpParameterIterator
The HttpParameterIterator is used for iterating through the form elements parsed by the HttpServer ob...
 
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:93
 
Abstract base class implemented by BasicAuthUser, FormAuthUser and DigestAuthUser.
Definition: AuthenticatedUser.h:243
 
Abstract interface class implemented by DigestAuthenticator, FormAuthenticator and DigestAuthenticato...
Definition: AuthenticatedUser.h:395
 
An abstract class, which you must implement, provides a method of authorizing an authenticated user.
Definition: AuthenticatedUser.h:112
 
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by severa...
Definition: BufPrint.h:122
 
Abstract interface class for reading the "dat" file generated by HttpLink.
Definition: CspRunTm.h:118
 
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
Definition: HttpServer.h:1818
 
Contains information about the physical socket connection.
Definition: HttpConnection.h:76
 
A cookie is used for exchanging a small amount of information between a HttpPage and a web browser.
Definition: HttpServer.h:516
 
const char * getComment() const
Returns the comment set for this cookie or null if the cookie comment is not set.
Definition: HttpServer.h:522
 
const char * getPath() const
Returns the path on the server to which the browser returns this cookie.
Definition: HttpServer.h:537
 
BaTime getMaxAge() const
Returns the maximum age of the cookie, specified in seconds; by default, 0 indicating the cookie will...
Definition: HttpServer.h:530
 
bool getSecure() const
Returns true if the browser is sending cookies only over a secure protocol, or false if the browser c...
Definition: HttpServer.h:542
 
const char * getDomain() const
Returns the domain name set for this cookie.
Definition: HttpServer.h:525
 
const char * getValue() const
Returns the value of the cookie.
Definition: HttpServer.h:550
 
bool getHttpOnly() const
Return the HttpOnly attribute.
Definition: HttpServer.h:547
 
const char * getName() const
Returns the name of the cookie.
Definition: HttpServer.h:533
 
An instance of the HttpDir class, which is a collection of zero or more resources,...
Definition: HttpServer.h:2364
 
HttpDir * getParent() const
Returns the parent directory or NULL if no parent.
Definition: HttpServer.h:2461
 
const char * getName() const
Returns the directory name.
Definition: HttpServer.h:2457
 
The web-server "Request Data" container.
Definition: HttpServer.h:258
 
const char * getBuf()
Get pointer to start of PUT/POST data.
Definition: HttpServer.h:293
 
S32 getBufSize()
Get size of internal buffer.
Definition: HttpServer.h:295
 
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
Definition: HttpServer.h:2256
 
const char * getName() const
Returns the page name.
Definition: HttpServer.h:2279
 
The HttpParameterIterator is used for iterating through the form elements parsed by the HttpServer ob...
Definition: HttpServer.h:432
 
const char * getValue() const
Returns the form value.
Definition: HttpServer.h:453
 
const char * getName() const
Return the form name.
Definition: HttpServer.h:451
 
A persistent container object for HTTP parameters.
Definition: HttpServer.h:357
 
static U32 calculateSize(struct HttpRequest *req)
Calculate the HttpParameter size.
Definition: HttpServer.h:395
 
const char * getParameter(const char *paramName)
Returns the value of a request parameter as a const char*, or null if the parameter does not exist.
Definition: HttpServer.h:399
 
static HttpParameter * clone(void *buf, struct HttpRequest *req)
Copy HTTP parameters to buf and return as a HttpParameter object.
Definition: HttpServer.h:397
 
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:808
 
This object is used when sending response messages back to the client.
Definition: HttpServer.h:1178
 
Use an instance of this class if you want to override the default web-server parameters.
Definition: HttpServer.h:2681
 
The Web Server.
Definition: HttpServer.h:2861
 
The interface to an HttpSession attribute.
Definition: HttpServer.h:1912
 
The HttpSession container class.
Definition: HttpServer.h:2144
 
Provides a way to identify a user across more than one page request or visit to a web site,...
Definition: HttpServer.h:1959
 
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:86
 
A mutual exclusion class.
Definition: ThreadLib.h:186
 
Interface class used by the Authentication classes.
Definition: AuthenticatedUser.h:174