39#define BASLIB_VER "6692"
40#define BASLIB_VER_NO 6692
78#include "TargConfig.h"
80#include "DoubleList.h"
81#include "SingleList.h"
95#define BA_COOKIE_ID "z9ZAqJtI"
146#define httpUnescape(s) httpUnescapeInternal(s,FALSE)
152#define httpFormUnescape(s) httpUnescapeInternal(s,TRUE)
217typedef int (*ZlibInflateInit2)(
struct z_stream_s* s,
int windowBits,
218 const char *version,
int stream_size);
220typedef int (*ZlibInflate)(
struct z_stream_s* s,
int flush);
221typedef int (*ZlibInflateEnd)(
struct z_stream_s* s);
236typedef struct HttpHeader
249BA_API
const char* HttpHeader_name(HttpHeader* o,
struct HttpRequest* req);
250BA_API
const char* HttpHeader_value(HttpHeader* o,
struct HttpRequest* req);
253inline const char* HttpHeader::name(
HttpRequest* req) {
254 return HttpHeader_name(
this, req); }
255inline const char* HttpHeader::value(
HttpRequest* req) {
256 return HttpHeader_value(
this, req); }
275 HttpInData_ParseHeader,
277 HttpInData_ReadBodyAndParseUrlEncData
278} HttpInData_ParseState;
300 HttpAllocator allocator;
309#define HttpAllocator_2Ptr(o, index) ((&(o)->buf[index]))
310#define HttpInData_lineStartPtr(o) \
311 HttpAllocator_2Ptr(&(o)->allocator,(o)->lineStartI)
313#define HttpInData_getBufSize(o) \
314 ((o)->lineStartI < (o)->allocator.index ? \
315 (o)->allocator.index-(o)->lineStartI : 0)
317#define HttpInData_getBuf(o) HttpInData_lineStartPtr(o)
322 return HttpInData_getBuf(
this); }
324 return HttpInData_getBufSize(
this); }
550#define HttpParameterIterator_hasMoreElements(o) ((o)->name != 0)
551#define HttpParameterIterator_getName(o) (o)->name
552#define HttpParameterIterator_getValue(o) (o)->value
557inline HttpParameterIterator::HttpParameterIterator(
HttpRequest* req) {
562 HttpParameterIterator_nextElement(
this); }
635 bool getSecure()
const {
return secure ? true :
false; }
717 int getVersion()
const {
return version; }
719 void setVersion(
int v);
749BA_API
void HttpCookie_destructor(
HttpCookie* o);
794#define HttpCookie_deleteCookie(o) (o)->deleteCookieFlag = TRUE;
814void HttpCookie_setVersion(
HttpCookie* o,
int v);
823inline HttpCookie::HttpCookie() { baAssert(0); }
824inline HttpCookie::~HttpCookie() { HttpCookie_destructor(
this); }
832 HttpCookie_deleteCookie(
this); }
842inline void HttpCookie::setVersion(
int v) {
843 HttpCookie_setVersion(
this, v); }
895 U16 contentTypeHOffs;
901BA_API
const char* HttpStdHeaders_zzGetValFromOffs(
904#define HttpStdHeaders_getConnection(o) \
905 HttpStdHeaders_zzGetValFromOffs(o,(o)->connectionHOffs)
906#define HttpStdHeaders_getHost(o) \
907 HttpStdHeaders_zzGetValFromOffs(o,(o)->hostHOffs)
908#define HttpStdHeaders_getContentType(o) \
909 HttpStdHeaders_zzGetValFromOffs(o,(o)->contentTypeHOffs)
910#define HttpStdHeaders_getContentLength(o) (o)->contentLength
915 return HttpStdHeaders_getConnection(
this); }
917 return HttpStdHeaders_getHost(
this); }
919 return HttpStdHeaders_getDomain(
this); }
921 return HttpStdHeaders_getContentType(
this); }
923 return HttpStdHeaders_getContentLength(
this); }
942 HttpMethod_Connect =0x00001,
943 HttpMethod_Get =0x00002,
944 HttpMethod_Head =0x00004,
945 HttpMethod_Options =0x00008,
947 HttpMethod_Patch =0x00010,
948 HttpMethod_Post =0x00020,
949 HttpMethod_Put =0x00040,
950 HttpMethod_Trace =0x00080,
953 HttpMethod_Copy =0x00100,
954 HttpMethod_Delete =0x00200,
955 HttpMethod_Lock =0x00400,
956 HttpMethod_Move =0x00800,
958 HttpMethod_Mkcol =0x01000,
959 HttpMethod_Propfind =0x02000,
960 HttpMethod_Proppatch =0x04000,
961 HttpMethod_Unlock =0x08000,
963 HttpMethod_Unknown =0x10000
968BA_API
HttpMethod HttpMethod_a2m(
const char* str);
1212 int setUserObj(
void* userObj,
bool overwrite=
false);
1217 HttpAllocator headerAlloc;
1218 HttpAllocator formAlloc;
1231 BaBool expect100Continue;
1243BA_API
int HttpRequest_checkOptions(
1245#define HttpRequest_getAuthenticatedUser(o) \
1246 AuthenticatedUser_get2(HttpRequest_getSession(o,FALSE))
1247#define HttpRequest_getConnection(o) HttpRequest_getCommand(o)->con
1248#define HttpRequest_getMethodType(o) (o)->methodType
1249#define HttpRequest_getMethod(o) HttpRequest_getMethod2((o)->methodType)
1250BA_API
const char* HttpRequest_getMethod2(
HttpMethod method);
1251#define HttpRequest_getServer(o) (o)->server
1252#define HttpRequest_getResponse(o) (&HttpRequest_getCommand(o)->response)
1267#define HttpRequest_getStdHeaders(o) (&(o)->stdH)
1276#define HttpRequest_getNoOfParameters(o) (o)->formLen
1281#define HttpRequest_getUserObj(o) (o)->userObj
1282BA_API
int HttpRequest_setUserObj(
1284#define HttpRequest_getBuffer(o) (&(o)->inData)
1299BA_API
int HttpRequest_pushBackData(
HttpRequest* o);
1306 HttpRequest* o,
const char* val,
size_t len,
int set);
1311 U32 methods,
bool addDefault){
1313 methods, addDefault ? TRUE : FALSE);}
1318 return HttpRequest_getAuthenticatedUser(
this); }
1320 return HttpRequest_getMethodType(
this); }
1322 return HttpRequest_getMethod(
this); }
1324 return HttpRequest_getMethod2(method); }
1326 return HttpRequest_getServer(
this); }
1332 return HttpRequest_getStdHeaders(
this); }
1346inline int HttpRequest::setUserObj(
void* userObj,
bool overwrite) {
1347 return HttpRequest_setUserObj(
this, userObj, overwrite); }
1348inline void* HttpRequest::getUserObj() {
1349 return HttpRequest_getUserObj(
this); }
1353 return HttpParameterIterator_hasMoreElements(
this); }
1355 return HttpRequest_getBuffer(
this); }
1364 U16 maxResponseHeader;
1448 const char*
encodeUrl(
const char* path);
1482 int forward(
const char* path);
1534 int include(
const char* path);
1600 int sendError(
int eCode,
const char* msg);
1626 int fmtError(
int eCode,
const char* fmt, ...);
1721 int setHeader(
const char* name,
const char* value,
bool replace=
true);
1770 char*
fmtHeader(
const char* name,
int valueLen,
bool replace=
true);
1796 int printf(
const char* fmt, ...);
1821 int write(
const void* data,
int len,
int useBuffering=TRUE);
1831 int write(
const char* data,
int useBuffering=TRUE);
1843 int send(
const void* data,
int len);
1889 int setUserObj(
void* userObj,
bool overwrite=
false);
1891 NameValMM nameValMM;
1897 char* encodedRedirectURL;
1902 HttpProtocol protocol;
1906 char printAndWriteInitialized;
1907 char useChunkTransfer;
1924#define HttpResponse_byteCount(o) ((o)->msgLen + (o)->bodyPrint->cursor)
1930BA_API
const char* HttpResponse_encodeRedirectURLWithParamOrSessionURL(
1932#define HttpResponse_encodeRedirectURLWithParam(o, path) \
1933 HttpResponse_encodeRedirectURLWithParamOrSessionURL(o, path, FALSE)
1934#define HttpResponse_encodeSessionURL(o, path) \
1935 HttpResponse_encodeRedirectURLWithParamOrSessionURL(o, path, TRUE)
1944#define HttpResponse_forward(o,path) HttpResponse_incOrForward(o,path,FALSE)
1945#define HttpResponse_getConnection(o) HttpResponse_getCommand(o)->con
1946#define HttpResponse_getRequest(o) (&HttpResponse_getCommand(o)->request)
1948#define HttpResponse_getBuf(o) (o)->bodyPrint->buf
1949#define HttpResponse_getBufSize(o) (o)->bodyPrint->bufSize
1950#define HttpResponse_getBufOffs(o) \
1951 ((o)->bodyPrint->buf + (o)->bodyPrint->cursor)
1952#define HttpResponse_getRemBufSize(o) \
1953 ((o)->bodyPrint->bufSize - (o)->bodyPrint->cursor)
1954#define HttpResponse_getUserObj(o) (o)->userObj
1955BA_API
int HttpResponse_incOrForward(
1961#define HttpResponse_include(o,path) HttpResponse_incOrForward(o,path,TRUE)
1962#define HttpResponse_isChunkTransfer(o) (o)->useChunkTransfer
1963#define HttpResponse_committed(o) (o)->headerSent
1964#define HttpResponse_isForward(o) ((o)->forwardCounter != 0)
1965#define HttpResponse_isInclude(o) ((o)->includeCounter != 0)
1966#define HttpResponse_initial(o) (!HttpResponse_isForward(o) && \
1967 !HttpResponse_isInclude(o))
1986BA_API
int HttpResponse_sendError1(
HttpResponse* o,
int eCode);
1987BA_API
int HttpResponse_sendError2(
HttpResponse* o,
int eCode,
const char* msg);
1996BA_API
int HttpResponse_fmtVError(
2001BA_API
int HttpResponse_fmtError(
2004 const char* fmt, ...);
2009BA_API
int HttpResponse_sendRedirectI(
2015#define HttpResponse_forceHttps HttpResponse_redirect2TLS
2017#define HttpResponse_setBufPos(o, pos) (o)->bodyPrint->cursor = pos
2026BA_API
int HttpResponse_checkContentType(
HttpResponse* o,
const char* type);
2050BA_API
int HttpResponse_setStatus(
HttpResponse* o,
int eCode);
2051BA_API
int HttpResponse_vprintf(
2075BA_API
int HttpResponse_setUserObj(
2077BA_API
int HttpResponse_printAndWriteInit(
HttpResponse* o);
2078BA_API
int HttpResponse_send100Continue(
HttpResponse* o);
2079BA_API
int HttpResponse_setChunkEncoding(
HttpResponse* o);
2080BA_API
const char* HttpResponse_getRespData(
HttpResponse* o,
int* len);
2081#define HttpResponse_getStatus(o) (o)->statusCode
2089 return HttpResponse_byteCount(
this); }
2093 return HttpResponse_encodeRedirectURLWithParam(
this, p); }
2099 return HttpResponse_forward(
this, path); }
2103 return HttpResponse_include(
this, path); }
2105 return HttpResponse_committed(
this) ? true :
false; }
2107 return HttpResponse_isForward(
this) ? true :
false; }
2109 return HttpResponse_isInclude(
this) ? true :
false; }
2111 return HttpResponse_initial(
this) ? true :
false; }
2121 return HttpResponse_sendError1(
this, eCode); }
2123 return HttpResponse_sendError2(
this, eCode, msg); }
2129 int retv; va_list varg;
2130 va_start(varg, fmt);
2131 retv = HttpResponse_fmtVError(
this, eCode, fmt, varg);
2145 const char* name,
const char* value,
bool replace) {
2150 const char* name,
int valueLen,
bool replace) {
2153 HttpResponse_setStatus(
this, eCode);}
2156 int retv; va_list varg; va_start(varg, fmt);
2157 retv = HttpResponse_vprintf(
this, fmt, varg); va_end(varg);
return retv;}
2168inline int HttpResponse::setUserObj(
void* userObj,
bool overwrite) {
2169 return HttpResponse_setUserObj(
this, userObj, overwrite); }
2212 struct LHttpCommand* lcmd;
2217#define HttpCommand_getRequest(o) (&(o)->request)
2218#define HttpCommand_getResponse(o) (&(o)->response)
2219#define HttpCommand_getConnection(o) (o)->con
2220#define HttpCommand_getServer(o) HttpConnection_getServer((o)->con)
2223 return HttpCommand_getRequest(
this); }
2225 return HttpCommand_getResponse(
this); }
2227 return HttpCommand_getConnection(
this); }
2229 return HttpCommand_getServer(
this);
2320#define HttpSessionAttribute_getSession(o) (o)->session
2328 return HttpSessionAttribute_getSession(
this); }
2342 void operator delete(
void* d) {
if(d)
::baFree(d); }
2343 void *
operator new(size_t,
void *place) {
return place; }
2344 void operator delete(
void*,
void *) { }
2449 void incrementLock();
2450 void decrementLock();
2462 BaTime maxInactiveInterval;
2514#define HttpSession_incrRefCntr(o) (o)->refCounter++
2519#define HttpSession_incrementLock(o) (o)->lockCounter++
2520#define HttpSession_decrementLock(o) do {\
2521 baAssert((o)->lockCounter > 0);\
2522 (o)->lockCounter--; } while(0)
2530#define HttpSession_getId(o) \
2531 ((U32)((ptrdiff_t)SplayTreeNode_getKey((SplayTreeNode*)(o))))
2532#define HttpSession_getAuthenticatedUser(o) AuthenticatedUser_get2((o))
2533#define HttpSession_getUseCounter(o) (o)->useCounter
2534#define HttpSession_getPeerName(o) (&(o)->peer)
2556 HttpSession_incrRefCntr(
this); }
2561 return HttpSession_getUseCounter(
this); }
2563 return HttpSession_getAuthenticatedUser(
this); }
2564inline void HttpSession::incrementLock() {HttpSession_incrementLock(
this);}
2565inline void HttpSession::decrementLock() {HttpSession_decrementLock(
this);}
2570 HttpSessionContainer_OK = 0,
2571 HttpSessionContainer_NoMemory,
2572 HttpSessionContainer_TooManySessions,
2573 HttpSessionContainer_NoPeerAddress
2574} HttpSessionContainer_ECode;
2594 DoubleList sessionList;
2595 DoubleList sessionTermList;
2596 DoubleLink* sessionLinkIter;
2600 HttpSessionContainer_ECode eCode;
2611#define HttpSessionContainer_setMaxSessions(o,max) (o)->maxSessions = max
2615 HttpSessionContainer_setMaxSessions(
this, max); }
2635#define HttpPageType_HttpPageSE 0x00020
2638typedef struct HttpPageNode
2640 struct HttpPageNode* next;
2700 void operator delete(
void* d) {
if(d)
::baFree(d); }
2701 void *
operator new(size_t,
void *place) {
return place; }
2702 void operator delete(
void*,
void *) { }
2761#define HttpPage_getName(o) (o)->name
2762#define HttpPage_isLinked(o) ((HttpPageNode*)(o))->next
2767#define HttpPage_service(o, request, response) \
2768 (o)->serviceCB(o, request, response)
2776 return HttpPage_isLinked(
this) ? true :
false;
2780 HttpPage_service(
this, request, response);
2795 const char* relPath,
2798#define HttpDirType_EhDir 0x00001
2799#define HttpDirType_HttpResRdr 0x00002
2800#define HttpDirType_AuthenticateDir 0x00008
2801#define HttpDirType_AuthenticateDirWrapper 0x00010
2827 void operator delete(
void* d) {
if(d)
::baFree(d); }
2828 void *
operator new(size_t,
void *place) {
return place; }
2829 void operator delete(
void*,
void *) { }
2851 HttpDir(
const char* name,
S8 priority=0);
2928 unsigned int nameLen);
2977 char*
makeAbsPath(
const char* relPath,
int relPathLen);
3070 HttpPageNode pageList;
3090 HttpDir* o,
const char* relPath,
int relPathLen);
3091#define HttpDir_getRootPath(o) HttpDir_makeAbsPath(o,"",0)
3096#define HttpDir_getFirstPage(o) \
3097 (o)->pageList.next != &(o)->pageList ? ((HttpPage*)(o)->pageList.next) : 0
3098#define HttpDir_getFirstDir(o) (o)->dirList
3107#define HttpDir_getNext(o) (o)->next
3108#define HttpDir_getName(o) (o)->name
3109#define HttpDir_getParent(o) (o)->parent
3123 HttpDir* iter,
const char* name,
unsigned int nameLen);
3132#define HttpDir_overloadService HttpDir_setService
3137#define HttpDir_isLinked(o) (o)->parent
3142#define HttpDir_setAuthenticator(o,authenticatorMA,authorizerMA) \
3143 (o)->authenticator = authenticatorMA,(o)->realm = authorizerMA
3149#define HttpDir_isAuthorized(o,user,method,path) \
3151 (user ? AuthorizerIntf_authorize((o)->realm,user,method,path) : FALSE) : \
3164 return HttpDir_getRootPath(
this); }
3179 unsigned int nameLen) {
3189 return HttpDir_isLinked(
this) ? true :
false; }
3192 HttpDir_setAuthenticator(
this,authenticator,authorizer);
3201typedef struct HttpLinkCon
3213 BaBool page404InProgress;
3373 U16 minResponseHeader;
3374 U16 maxResponseHeader;
3377 U16 noOfHttpCommands;
3378 U16 noOfHttpConnections;
3441typedef DoubleList HttpLinkConList;
3444typedef void (*LspOnTerminateRequest)(
struct LHttpCommand* lcmd);
3466 void operator delete(
void* d) {
if(d)
::baFree(d); }
3467 void *
operator new(size_t,
void *place) {
return place; }
3468 void operator delete(
void*,
void *) { }
3572 const char* virtualDirRootPath,
3575 struct AuthUserList* getAuthUserList(
const char* name);
3630 int setUserObj(
void* userObj,
bool overwrite=
false);
3649 static void setErrHnd(UserDefinedErrHandler e);
3652 static int setZlib(ZlibInflateInit2 init,
3653 ZlibInflate inflate,
3654 ZlibInflateEnd end){
3655 (void)init; (void)inflate; (void)end;
3666 DoubleList commandPool;
3667 DoubleList cmdReqList;
3669 HttpLinkConList freeList;
3670 HttpLinkConList readyList;
3671 HttpLinkConList connectedList;
3672 HttpRootDir rootDirContainer;
3675 HttpLinkCon* connections;
3678 SingleList waitForConClose;
3679 LspOnTerminateRequest lspOnTerminateRequest;
3680 int commandPoolSize;
3681 U16 noOfConnections;
3682 S16 maxHttpRequestLen;
3688void HttpServer_AsynchProcessDir(
HttpServer* o,
3692#define HttpServer_setThreadPoolIntf(o, intf) (o)->threadPoolIntf=intf
3693#define HttpServer_luaenv(o) (o)->luaenv
3715 const char* virtualDirRootPath,
3722 const char* virtualDirRootPath,
3724#define HttpServer_getAuthUserList(o, name) \
3725 (AuthUserList*)SplayTree_find(&(o)->authUserTree, name)
3726#define HttpServer_getDispatcher(o) (o)->dispatcher
3727#define HttpServer_getFirstRootDir(o) \
3728 HttpDir_getFirstDir((HttpDir*)&(o)->rootDirContainer)
3729#define HttpServer_getUserObj(o) (o)->userObj
3730#define HttpServer_getSessionContainer(o) (&(o)->sessionContainer)
3731#define HttpServer_getMutex(o) SoDisp_getMutex((o)->dispatcher)
3737void HttpServer_doLingeringClose(
3747BA_API
void HttpServer_setErrHnd(UserDefinedErrHandler e);
3748void HttpServer_initStatic(
void);
3749int HttpServer_termOldestIdleCon(
HttpServer* o);
3754#define HttpServer_get404Page(o) (o)->rootDirContainer.page404
3755BA_API
int HttpServer_setUserObj(
3757#define HttpServer_termAllSessions(o) \
3758 HttpSessionContainer_destructor(&(o)->sessionContainer)
3760#define HttpServer_setZlib(init,inflate,end);
3770 return HttpServer_getMutex(
this);
3775 const char* virtualDirRootPath,
3778inline struct AuthUserList* HttpServer::getAuthUserList(
const char* name) {
3779 return HttpServer_getAuthUserList(
this,name); }
3781 return HttpServer_getDispatcher(
this); }
3783 return HttpServer_getFirstRootDir(
this); }
3785 return HttpServer_getSessionContainer(
this); }
3789 HttpServer_initStatic(); }
3791 HttpServer_setErrHnd(e); }
3795 return HttpServer_get404Page(
this); }
3796inline int HttpServer::setUserObj(
void* userObj,
bool overwrite) {
3797 return HttpServer_setUserObj(
this, userObj, overwrite); }
3804 return HttpRequest_getResponse(
this); }
3806 return HttpRequest_getConnection(
this); }
3808 return HttpResponse_getRequest(
this); }
3810 return HttpResponse_getCommand(
this); }
3812 return HttpRequest_getCommand(
this); }
3821#if !BA_ENABLE_SHARKSSL || SHARKSSL_PSA_CONSUMER
3823#define SHARKSSL_MD5_HASH_LEN 16
3825typedef struct SharkSslMd5Ctx
3832SHARKSSL_API
void SharkSslMd5Ctx_constructor(SharkSslMd5Ctx* ctx);
3833SHARKSSL_API
void SharkSslMd5Ctx_append(SharkSslMd5Ctx* ctx,
const U8* data,
U32 len);
3834SHARKSSL_API
void SharkSslMd5Ctx_finish(SharkSslMd5Ctx* ctx,
U8 digest[SHARKSSL_MD5_HASH_LEN]);
3835SHARKSSL_API
int sharkssl_md5(
const U8*,
U16,
U8*);
3838#if !BA_ENABLE_SHARKSSL || SHARKSSL_PSA_CONSUMER
3839#define SHARKSSL_SHA1_HASH_LEN 20
3841typedef struct SharkSslSha1Ctx
3848SHARKSSL_API
void SharkSslSha1Ctx_constructor(SharkSslSha1Ctx* ctx);
3849SHARKSSL_API
void SharkSslSha1Ctx_append(SharkSslSha1Ctx* ctx,
const U8* data,
U32 len);
3850SHARKSSL_API
void SharkSslSha1Ctx_finish(SharkSslSha1Ctx*,
U8 digest[SHARKSSL_SHA1_HASH_LEN]);
3851#if SHARKSSL_PSA_CONSUMER
3852SHARKSSL_API
int sharkssl_sha1(
const U8* data,
U32 len,
U8* digest);
3854#if !BA_ENABLE_SHARKSSL
3855typedef void SharkSsl;
BAS status codes and fatal-error reporting.
BaFatalErrorCodes
Fatal conditions reported to UserDefinedErrHandler, not ordinary returns.
Definition: BaErrorCodes.h:49
#define HttpConnection_getServer(o)
Definition: HttpConnection.h:127
struct HttpParameter HttpParameter
A persistent container object for HTTP parameters.
BA_API void httpFmtDate(char *buf, U16 bufLen, BaTime t)
Format an HTTP date in GMT.
BA_API char * httpEscape(char *out, const char *in)
Encodes characters that cannot be in a http URL.
BA_API HttpParameter * HttpParameter_clone(void *buf, struct HttpRequest *req)
Copy HTTP parameters to buf and return as a HttpParameter object.
BA_API char * httpUnescapeInternal(char *from, BaBool isForm)
Decode percent followed by two hex digits in place.
struct HttpInData HttpInData
The web-server "Request Data" container.
BA_API const char * HttpParameter_getParameter(HttpParameter *o, const char *paramName)
Returns the value of a request parameter as a const char*, or null if the parameter does not exist.
BA_API U32 HttpParameter_calculateSize(struct HttpRequest *req)
Calculate the HttpParameter size.
BA_API AuthenticatedUser * AuthenticatedUser_get2(HttpSession *session)
Find the authenticated-user session attribute.
void(* CspInit)(struct HttpDir *cspRoot, struct CspReader *reader)
Function prototype for the "initialize function" generated by CspLink.
Definition: HttpServer.h:209
void * baMalloc(size_t size)
Allocate uninitialized storage using the target's configured allocator.
void baFree(void *p)
Release storage using the target's configured allocator.
BaTime getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of second...
Definition: HttpServer.h:2541
BA_API BaTime HttpSession_getLastAccessedTime(HttpSession *o)
Returns the last time the client sent a request associated with this session, as the number of second...
void deleteCookie()
Specifies a path for the cookie to which the client should return the cookie.
Definition: HttpServer.h:831
HttpHeader * getHeaders(int *len)
Return an HTTP header iterator that can iterate and fetch all the HTTP headers.
Definition: HttpServer.h:1344
BA_API int HttpResponse_flush(HttpResponse *o)
Forces any content in the buffer to be written to the client.
int include(const char *path)
Includes the content of a resource (servlet, CSP page, HTML file) in the response.
Definition: HttpServer.h:2102
BaTime getCreationTime()
Returns the time when this session was created, measured in seconds since midnight January 1,...
Definition: HttpServer.h:2539
int setMaxAge(BaTime seconds)
Sets header "Cache-Control: max-age=seconds".
Definition: HttpServer.h:2147
int setDateHeader(const char *name, BaTime time)
Sets a response header with the given name and date-value.
Definition: HttpServer.h:2142
HttpDir * getNext()
Returns the next dir in the parent list.
Definition: HttpServer.h:3175
const char * getRequestURI()
Returns the pathname.
Definition: HttpServer.h:1327
const char * containsHeader(const char *name)
Searches the internal response header database for a header with the specified name.
Definition: HttpServer.h:2086
const char * getContentType()
Read the request's Content-Type header.
Definition: HttpServer.h:920
BA_API int HttpCookie_setDomain(HttpCookie *o, const char *pattern)
Specifies the domain within which this cookie should be presented.
BA_API int HttpResponse_setContentLength(HttpResponse *o, BaFileSize len)
Sets the "Content-Length" parameter value.
BA_API int HttpServer_insertCSP(HttpServer *o, CspInit cspInit, const char *virtualDirRootPath, struct CspReader *reader)
Insert and initialize a CSP Virtual Directory.
BA_API int HttpResponse_redirect2TLS(HttpResponse *o)
Prepares an HTTPS redirect (301) for a non-secure connection.
const char * getHost()
Read the request's Host header.
Definition: HttpServer.h:916
BA_API BaTime HttpCookie_getMaxAge(HttpCookie *o)
Read the stored cookie lifetime in seconds.
BA_API int HttpResponse_setResponseBuf(HttpResponse *o, BufPrint *buf, BaBool useDefBuffer)
This is an advanced function that makes it possible to redirect the output, which is normally sent to...
BA_API int HttpServerConfig_setRequest(HttpServerConfig *o, S16 min, S16 max)
Set the size of the HTTP request buffer.
int flush()
Forces any content in the buffer to be written to the client.
Definition: HttpServer.h:2096
void(* HttpSessionAttribute_Destructor)(struct HttpSessionAttribute *o)
HttpSessionAttribute termination callback function.
Definition: HttpServer.h:2248
int sendError(int eCode)
Sends an error response as a simple HTML page to the client using the specified status code.
Definition: HttpServer.h:2120
int forward(const char *path)
Forwards a request from a servlet to another resource (servlet, CSP file, or HTML file).
Definition: HttpServer.h:2098
BA_API BufPrint * HttpResponse_getWriter(HttpResponse *o)
Returns a BufPrint object that can send any type of data to the client.
void setHttpOnly(bool flag)
Marks or unmarks this Cookie as HttpOnly.
Definition: HttpServer.h:837
int setContentLength(BaFileSize len)
Sets the "Content-Length" parameter value.
Definition: HttpServer.h:2138
BA_API HttpHeader * HttpRequest_getHeaders(HttpRequest *o, int *len)
Return an HTTP header iterator that can iterate and fetch all the HTTP headers.
BA_API HttpDir_Service HttpDir_setService(HttpDir *o, HttpDir_Service s)
Replace the original service function in HttpDir with your own.
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:835
BA_API void HttpCookie_setHttpOnly(HttpCookie *o, BaBool flag)
Marks or unmarks this Cookie as HttpOnly.
BA_API const char * HttpCookie_getComment(HttpCookie *o)
Returns the comment set for this cookie or null if the cookie comment is not set.
BA_API void HttpSession_terminate(HttpSession *o)
Unbinds any objects bound to this session object, runs the HttpSession destructor,...
HttpPage * findPage(HttpPage *iter, const char *name)
Searches for a page in this directory node.
Definition: HttpServer.h:3176
BA_API int HttpResponse_resetBuffer(HttpResponse *o)
Clears the content of the underlying buffer in the response without clearing headers or status code.
HttpServer * getServer()
Returns the web server object.
Definition: HttpServer.h:1325
int resetHeaders()
Removes all HTTP headers.
Definition: HttpServer.h:2116
BA_API HttpSessionAttribute * HttpSession_getAttribute(HttpSession *o, const char *name)
Returns the object bound with the specified name in this session, or null if no object is bound under...
struct HttpServer * getServer()
Get the web-server object.
Definition: HttpServer.h:2228
BA_API int HttpParameterIterator_constructor2(HttpParameterIterator *o, HttpParameter *param)
Initialize an iterator and select its first element.
BA_API const char * HttpCookie_getValue(HttpCookie *o)
Returns the value of the cookie.
HttpRequest * getRequest()
Get the request object.
Definition: HttpServer.h:2222
BA_API void HttpCookie_setMaxAge(HttpCookie *o, BaTime expiry)
Sets the maximum age of the cookie in seconds.
int insertPage(HttpPage *page)
Insert a page in the directory.
Definition: HttpServer.h:3167
BA_API HttpPage * HttpDir_getPage(HttpDir *o, const char *name)
Returns the page with the name given or NULL if not found.
int setAttribute(HttpSessionAttribute *value)
Binds an object to this session, using the name specified.
Definition: HttpServer.h:2551
BA_API int HttpResponse_redirect(HttpResponse *o, const char *path)
Internally redirects the request to another resource.
HttpMethod getMethodType()
Returns the method type.
Definition: HttpServer.h:1319
int send(const void *data, int len)
Used when sending raw data to the client.
Definition: HttpServer.h:2164
BA_API int HttpServerConfig_setNoOfHttpCommands(HttpServerConfig *o, U16 size)
The number of HttpCommand instances created by the web-server.
HttpResponse * getResponse()
Get the response object.
Definition: HttpServer.h:2224
int removeResponseBuf()
Remove buffer set by using setResponseBuf.
Definition: HttpServer.h:2114
BA_API const char * HttpResponse_containsHeader(HttpResponse *o, const char *name)
Searches the internal response header database for a header with the specified name.
BA_API int HttpResponse_send(HttpResponse *o, const void *data, int len)
Used when sending raw data to the client.
BA_API const char * HttpRequest_getHeaderValue(HttpRequest *o, const char *name)
Returns the value of the specified request header.
BA_API HttpPage * HttpDir_findPage(HttpDir *o, HttpPage *iter, const char *name)
Searches for a page in this directory node.
HttpMethod
HTTP method types.
Definition: HttpServer.h:941
BA_API int HttpRequest_wsUpgrade(HttpRequest *o)
Validate and send an HTTP/1.1 WebSocket version-13 handshake.
HttpConnection * getConnection()
Returns the connection object associated with this request.
Definition: HttpServer.h:3805
const char * getDomain()
Read the lower-case Host value without its port.
Definition: HttpServer.h:918
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 optional AuthorizerIntf.
Definition: HttpServer.h:3190
struct HttpConnection * getConnection()
Get the current connection object that the HttpCommand instance is bound with.
Definition: HttpServer.h:2226
int sendBufAsTxtError(int eCode)
Sends the data formatted into the HttpResponse buffer as an error message to the client.
Definition: HttpServer.h:2126
bool isForward() const
Returns true if this is a forward request from another servlet or CSP file.
Definition: HttpServer.h:2106
AuthenticatedUser * getAuthenticatedUser()
Returns the authenticated user or NULL if user is not authenticated.
Definition: HttpServer.h:1317
int unlink()
Unlinks/removes the page from the parent directory.
Definition: HttpServer.h:2778
BA_API int HttpResponse_setMaxAge(HttpResponse *response, BaTime seconds)
Sets header "Cache-Control: max-age=seconds".
HttpServer * getServer()
Get the server object.
Definition: HttpServer.h:2545
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:3423
BA_API BaTime HttpSession_getCreationTime(HttpSession *o)
Returns the time when this session was created, measured in seconds since midnight January 1,...
bool hasMoreElements()
Returns true if more elements.
Definition: HttpServer.h:1352
HttpStdHeaders * getStdHeaders()
Returns an object containing standard HTTP headers.
Definition: HttpServer.h:1331
const char * getHeaderValue(const char *name)
Returns the value of the specified request header.
Definition: HttpServer.h:1335
int setDefaultHeaders()
Sets the most common header values in servlet and CSP files.
Definition: HttpServer.h:2166
BA_API int HttpServer_insertDir(HttpServer *o, const char *virtualDirRootPath, HttpDir *dir)
Insert a directory node into the virtual file system.
BA_API int HttpResponse_setHeader(HttpResponse *o, const char *name, const char *value, BaBool replace)
Sets a HTTP response header with the given name and value.
int resetBuffer()
Clears the content of the underlying buffer in the response without clearing headers or status code.
Definition: HttpServer.h:2118
int insertCSP(CspInit cspInit, const char *virtualDirRootPath, struct CspReader *reader)
Insert and initialize a CSP Virtual Directory.
Definition: HttpServer.h:3774
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:2090
bool initial() const
Returns true if this is the initial page.
Definition: HttpServer.h:2110
~HttpServer()
Stop using the server before destruction.
Definition: HttpServer.h:3765
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:3790
void terminate()
Unbinds any objects bound to this session object, runs the HttpSession destructor,...
Definition: HttpServer.h:2547
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:2773
BA_API void HttpDir_constructor(HttpDir *o, const char *name, S8 priority)
Constructor for creating a sub-directory.
void nextElement()
Advance to the next element.
Definition: HttpServer.h:561
SBaFileSize getContentLength()
Read the request's declared Content-Length in bytes.
Definition: HttpServer.h:922
U32 byteCount()
Returns number of bytes sent thus far.
Definition: HttpServer.h:2088
int setCommit(U16 size)
Set the size of the HTTP response commit buffer.
Definition: HttpServer.h:3429
BA_API BaBool HttpCookie_getSecure(HttpCookie *o)
Read the cookie's Secure flag.
HttpDir()
Constructor for creating a root dir, a root dir has no name.
Definition: HttpServer.h:3155
struct HttpServer HttpServer
Route and process HTTP requests using a borrowed dispatcher.
int setValue(const char *newValue)
Assigns a new value to a cookie after the cookie is created.
Definition: HttpServer.h:839
BA_API HttpDir * HttpDir_getDir(HttpDir *o, const char *name)
Returns the first directory with the name given or NULL if not found.
HttpCookie * getCookie(const char *name)
Returns the requested cookie or NULL if no cookie matches the name.
Definition: HttpServer.h:1337
BA_API const char * HttpCookie_getDomain(HttpCookie *o)
Returns the domain name set for this cookie.
ThreadMutex * getMutex()
Get the dispatcher mutex.
Definition: HttpServer.h:3769
BA_API struct HttpSession * HttpRequest_getSession(HttpRequest *o, BaBool create)
Returns the current HttpSession associated with this request, or if there is no current session and c...
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:2779
void setMaxAge(BaTime expiry)
Sets the maximum age of the cookie in seconds.
Definition: HttpServer.h:829
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:2112
HttpSessionContainer * getSessionContainer()
Get the HttpSessionContainer.
Definition: HttpServer.h:3784
HttpDir * getFirstRootDir()
Returns the first root directory.
Definition: HttpServer.h:3782
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:2537
AuthenticatedUser * getAuthenticatedUser()
Returns the AuthenticatedUser if user is authenticated.
Definition: HttpServer.h:2562
BA_API BaTime HttpSession_getMaxInactiveInterval(HttpSession *o)
Returns the maximum time interval, in seconds, that the session container will keep this session open...
BA_API int HttpResponse_setDefaultHeaders(HttpResponse *o)
Sets the most common header values in servlet and CSP files.
int setContentType(const char *type)
Sets the "Content-Type" parameter value.
Definition: HttpServer.h:2140
void(* HttpPage_Service)(struct HttpPage *page, HttpRequest *request, HttpResponse *response)
The HttpPage service function.
Definition: HttpServer.h:2630
struct HttpCookie HttpCookie
A cookie is used for exchanging a small amount of information between a HttpPage and a web browser.
BA_API const char * HttpRequest_getRequestURI(HttpRequest *o)
Returns the pathname.
U32 getId()
Returns a unique identifier assigned to this session.
Definition: HttpServer.h:2559
BA_API int HttpResponse_sendBufAsError(HttpResponse *o, int eCode)
Sends the data formatted into the HttpResponse buffer as an error message to the client.
BA_API int HttpServer_insertRootDir(HttpServer *o, HttpDir *dir)
Insert a root directory node.
BA_API const char * HttpRequest_getRequestURL(HttpRequest *o, BaBool forceHttps)
Reconstructs the URL the client used to make the request.
BA_API BaBool HttpRequest_checkTime(HttpRequest *o, struct HttpResponse *resp, BaTime time)
Parses and checks if the "If-Modified-Since" time is equal or greater than "time".
int setResponseHeader(U16 min, U16 max)
Set the size of the HTTP response header buffer.
Definition: HttpServer.h:3425
BA_API int HttpServerConfig_setCommit(HttpServerConfig *o, U16 size)
Set the size of the HTTP response commit buffer.
void set404Page(const char *page404)
Set a more user friendly 404 page.
Definition: HttpServer.h:3792
BA_API void HttpServer_set404Page(HttpServer *o, const char *page404)
Set a more user friendly 404 page.
const char * encodeRedirectURLWithParam(const char *pathName)
This method is similar to HttpResponse::encodeRedirectURL, but this method also includes all URL-enco...
Definition: HttpServer.h:2092
BA_API void HttpPage_destructor(HttpPage *o)
The HttpPage destructor unlinks the page from the parent directory.
BA_API int HttpResponse_removeResponseBuf(HttpResponse *o)
Remove buffer set by using setResponseBuf.
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:3788
BA_API int HttpResponse_resetHeaders(HttpResponse *o)
Removes all HTTP headers.
struct HttpServer * getServer()
Definition: HttpServer.h:3813
BA_API struct HttpServer * HttpSession_getServer(HttpSession *o)
Get the server object.
BufPrint * getWriter()
Returns a BufPrint object that can send any type of data to the client.
Definition: HttpServer.h:2160
BA_API const char * HttpRequest_getParameter(HttpRequest *o, const char *paramName)
Returns the value of a request parameter as a const char* or null if the parameter does not exist.
BA_API int HttpCookie_setValue(HttpCookie *o, const char *newValue)
Assigns a new value to a cookie after the cookie is created.
int write(const void *data, int len, int useBuffering=TRUE)
Used for sending pre-formatted data to the client.
Definition: HttpServer.h:2162
BA_API const char * HttpResponse_encodeRedirectURL(HttpResponse *o, const char *pathName)
Encodes the specified URL into an absolute URL, or if encoding is not needed, returns the URL unchang...
int setMaxSessions(U16 size)
Maximum allowed active HttpSession objects.
Definition: HttpServer.h:3435
HttpInData * getBuffer()
Get the internal rec buffer.
Definition: HttpServer.h:1354
BA_API int HttpCookie_setComment(HttpCookie *o, const char *purpose)
Specifies a comment that describes a cookie's purpose.
BA_API int HttpServerConfig_setResponseData(HttpServerConfig *o, U16 size)
The HttpResponse object stores formatted data in the response data buffer.
const char * encodeUrl(const char *path)
Escape a URL path into a response-owned buffer.
Definition: HttpServer.h:2094
BA_API int HttpResponse_setContentType(HttpResponse *o, const char *type)
Sets the "Content-Type" parameter value.
int setNoOfHttpCommands(U16 size)
The number of HttpCommand instances created by the web-server.
Definition: HttpServer.h:3431
HttpDir * createOrGet(const char *name)
Returns a sub-directory with the given name.
Definition: HttpServer.h:3181
bool authenticateAndAuthorize(HttpCommand *cmd, const char *path)
Authenticate and authorize the user.
Definition: HttpServer.h:3194
int(* HttpDir_Service)(struct HttpDir *o, const char *relPath, HttpCommand *cmd)
The HttpDir service callback function.
Definition: HttpServer.h:2794
HttpServer(SoDisp *dispatcher, HttpServerConfig *cfg=0)
Create a Web Server object.
Definition: HttpServer.h:3763
struct HttpCommand HttpCommand
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
BA_API void HttpServer_destructor(HttpServer *o)
Stop using the server before destruction.
BA_API void HttpSession_decrRefCntr(HttpSession *o)
Decrements the session reference counter.
BA_API int HttpCookie_setPath(HttpCookie *o, const char *uri)
Set the cookie path.
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:2149
bool isInclude() const
Returns true if this is an include from another servlet or CSP file.
Definition: HttpServer.h:2108
int unlink()
Unlinks/removes the directory from the parent directory.
Definition: HttpServer.h:3187
char * getRootPath()
Calculates the root of where the HttpDir instance is installed in the virtual file system.
Definition: HttpServer.h:3163
BA_API HttpDir * HttpDir_findDir(HttpDir *iter, const char *name, unsigned int nameLen)
Searches for a sub-directory in this directory node.
int checkMethods(HttpResponse *resp, U32 methods, bool addDefault=TRUE)
Check allowed HTTP methods on the original request.
Definition: HttpServer.h:1310
BA_API int HttpParameterIterator_constructor(HttpParameterIterator *o, struct HttpRequest *req)
Initialize an iterator and select its first element.
const char * getVersion()
Returns the HTTP version as a string, normally "1.1".
Definition: HttpServer.h:1333
void BA_API HttpPage_constructor(HttpPage *o, HttpPage_Service service, const char *name)
The HttpPage constructor.
BA_API HttpDir * HttpDir_createOrGet(HttpDir *o, const char *name)
Returns a sub-directory with the given name.
int printf(const char *fmt,...)
printf is used for sending formatted data to the client.
Definition: HttpServer.h:2155
BA_API BaBool HttpCookie_getHttpOnly(HttpCookie *o)
Return the HttpOnly attribute.
int redirect2TLS()
Prepares an HTTPS redirect (301) for a non-secure connection.
Definition: HttpServer.h:2136
BA_API int HttpSession_removeAttribute(HttpSession *o, const char *name)
Removes the object bound with the specified name from this session.
BA_API const char * HttpCookie_getPath(HttpCookie *o)
Returns the path on the server to which the browser returns this cookie.
BA_API const char * HttpResponse_encodeUrl(HttpResponse *o, const char *path)
Escape a URL path into a response-owned buffer.
BA_API int HttpPage_unlink(HttpPage *o)
Unlinks/removes the page from the parent directory.
HttpPage * getFirstPage()
Returns the first page.
Definition: HttpServer.h:3169
SoDisp * getDispatcher()
Returns the dispatcher object.
Definition: HttpServer.h:3780
BA_API char * HttpResponse_fmtHeader(HttpResponse *o, const char *name, int valueLen, BaBool replace)
Pre-allocate memory for a {name, value} pair in the response header database.
BA_API int HttpServerConfig_setResponseHeader(HttpServerConfig *o, U16 min, U16 max)
Set the size of the HTTP response header buffer.
HttpDir * getDir(const char *name)
Returns the first directory with the name given or NULL if not found.
Definition: HttpServer.h:3171
int wsUpgrade()
Validate and send an HTTP/1.1 WebSocket version-13 handshake.
Definition: HttpServer.h:1341
BA_API int HttpDir_unlink(HttpDir *o)
Unlinks/removes the directory from the parent directory.
BA_API int HttpRequest_checkMethods(HttpRequest *o, struct HttpResponse *resp, U32 methods, BaBool addDefault)
Check allowed HTTP methods on the original request.
static const char * getStatusCode(int code)
Return a short description for common HTTP error codes.
Definition: HttpServer.h:3798
BA_API int HttpServerConfig_setMaxSessions(HttpServerConfig *o, U16 size)
Maximum allowed active HttpSession objects.
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:3161
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:3786
U32 getUseCounter()
Get the session usage counter.
Definition: HttpServer.h:2560
bool committed() const
Returns a boolean indicating if the response has been committed.
Definition: HttpServer.h:2104
BA_API int HttpResponse_write(HttpResponse *o, const void *data, int len, int useBuffering)
Used for sending pre-formatted data to the client.
BA_API int HttpDir_authenticateAndAuthorize(HttpDir *o, HttpCommand *cmd, const char *path)
Authenticate and authorize the user.
int redirect(const char *path)
Internally redirects the request to another resource.
Definition: HttpServer.h:2100
BA_API void HttpSession_setMaxInactiveInterval(HttpSession *o, BaTime interval)
Specifies the time, in seconds, between client requests before the session container will invalidate ...
void incrRefCntr()
Increments the session reference counter.
Definition: HttpServer.h:2555
const char * getConnection()
Read the request's Connection header.
Definition: HttpServer.h:914
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:1339
void decrRefCntr()
Decrements the session reference counter.
Definition: HttpServer.h:2557
const char * getRequestURL(bool forceHttps=false)
Reconstructs the URL the client used to make the request.
Definition: HttpServer.h:1329
BA_API int HttpServerConfig_setNoOfHttpConnections(HttpServerConfig *o, U16 size)
Number of HttpConnection instances.
BA_API HttpCookie * HttpResponse_createCookie(struct HttpResponse *o, const char *name)
Create a cookie.
BA_API void HttpDir_destructor(HttpDir *o)
Unlink this directory and notify all child pages/directories through their service callbacks with NUL...
HttpCommand * getCommand()
Get the HttpCommand object.
Definition: HttpServer.h:3811
int insertDir(HttpDir *dir)
Insert a sub-directory.
Definition: HttpServer.h:3165
void setMaxInactiveInterval(BaTime interval)
Specifies the time, in seconds, between client requests before the session container will invalidate ...
Definition: HttpServer.h:2553
void setMaxSessions(int max)
Set the maximum number of session objects.
Definition: HttpServer.h:2614
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:2775
const char * get404Page()
Returns a pointer to the current 404 page, if any.
Definition: HttpServer.h:3794
HttpCommand * getCommand()
Get the HttpCommand object.
Definition: HttpServer.h:3809
BA_API HttpSession * HttpServer_getSession(HttpServer *o, U32 id)
Returns the HttpSession associated with id or NULL if not found.
static HttpDir * findDir(HttpDir *iter, const char *name, unsigned int nameLen)
Searches for a sub-directory in this directory node.
Definition: HttpServer.h:3178
int setPath(const char *uri)
Set the cookie path.
Definition: HttpServer.h:833
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:1350
BA_API void HttpSessionAttribute_constructor(HttpSessionAttribute *o, const char *name, HttpSessionAttribute_Destructor d)
Initialize a session attribute.
HttpServerConfig()
The constructor sets up the default parameters.
Definition: HttpServer.h:3421
const char * getMethod()
Returns a string representation of the value returned by HttpRequest::getMethodType.
Definition: HttpServer.h:1321
BaTime getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the session container will keep this session open...
Definition: HttpServer.h:2543
BA_API const char * HttpServer_getStatusCode(int code)
Return a short description for common HTTP error codes.
BA_API void HttpSessionAttribute_destructor(HttpSessionAttribute *o)
Terminate an unattached attribute and release its copied name.
HttpCookie * createCookie(const char *name)
Create a cookie.
Definition: HttpServer.h:2084
HttpPage * getPage(const char *name)
Returns the page with the name given or NULL if not found.
Definition: HttpServer.h:3173
BA_API const char * HttpCookie_getName(HttpCookie *o)
Returns the name of the cookie.
int setComment(const char *purpose)
Specifies a comment that describes a cookie's purpose.
Definition: HttpServer.h:825
BA_API int HttpDir_insertDir(HttpDir *o, HttpDir *dir)
Insert a sub-directory.
int fmtError(int eCode, const char *fmt,...)
This method implements a printf like implementation for formatting and sending an error message.
Definition: HttpServer.h:2128
BA_API const char * HttpRequest_getVersion(HttpRequest *o)
Returns the HTTP version as a string, normally "1.1".
struct HttpPage HttpPage
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
BA_API int HttpResponse_sendRedirect(HttpResponse *o, const char *url)
Sends a temporary redirect (302) response to the client using the specified redirect location URL.
HttpDir_Service setService(HttpDir_Service s)
Replace the original service function in HttpDir with your own.
Definition: HttpServer.h:3183
HttpDir * getFirstDir()
Returns the first sub-directory.
Definition: HttpServer.h:3170
int setDomain(const char *pattern)
Specifies the domain within which this cookie should be presented.
Definition: HttpServer.h:827
bool isLinked()
Returns true if this directory node is installed into a parent directory.
Definition: HttpServer.h:3188
HttpResponse * getResponse()
Returns the HttpResponse object.
Definition: HttpServer.h:3803
int insertDir(const char *virtualDirRootPath, HttpDir *dir)
Insert a directory node into the virtual file system.
Definition: HttpServer.h:3772
void setStatus(int statusCode)
Sets the status code for this response.
Definition: HttpServer.h:2152
BA_API void HttpDir_p403(HttpDir *o, const char *p403)
Set a 403 denied request handler.
int insertRootDir(HttpDir *dir)
Insert a root directory node.
Definition: HttpServer.h:3767
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:2144
HttpRequest * getRequest()
Get the HttpRequest object.
Definition: HttpServer.h:3807
BA_API void HttpCookie_setSecure(HttpCookie *o, BaBool flag)
Inform the browser whether the cookie should be sent only using a secure protocol such as HTTPS – i....
BA_API void HttpServer_constructor(HttpServer *, SoDisp *, HttpServerConfig *)
Initialize a server in caller-provided storage (first argument), using a required borrowed dispatcher...
void p403(const char *p403)
Set a 403 denied request handler.
Definition: HttpServer.h:3185
BA_API void HttpCookie_activate(HttpCookie *o)
Activates the cookie.
BA_API int HttpResponse_setDateHeader(HttpResponse *o, const char *name, BaTime t)
Set a copied date header; call before response commitment.
HttpSession * getSession()
Get the session object.
Definition: HttpServer.h:2327
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:1315
BA_API int HttpResponse_sendBufAsTxtError(HttpResponse *o, int eCode)
Sends the data formatted into the HttpResponse buffer as an error message to the client.
void activate()
Activates the cookie.
Definition: HttpServer.h:845
BA_API HttpCookie * HttpRequest_getCookie(HttpRequest *o, const char *name)
Returns the requested cookie or NULL if no cookie matches the name.
int sendRedirect(const char *url)
Sends a temporary redirect (302) response to the client using the specified redirect location URL.
Definition: HttpServer.h:2134
BA_API int HttpSession_setAttribute(HttpSession *o, HttpSessionAttribute *value)
Binds an object to this session, using the name specified.
int setResponseData(U16 size)
The HttpResponse object stores formatted data in the response data buffer.
Definition: HttpServer.h:3427
BA_API int HttpSession_fmtSessionId(HttpSession *o, U8 *buf, size_t bufSize)
Format the full session token as hexadecimal text.
int removeAttribute(const char *name)
Removes the object bound with the specified name from this session.
Definition: HttpServer.h:2549
BA_API int HttpDir_insertPage(HttpDir *o, HttpPage *page)
Insert a page in the directory.
int setNoOfHttpConnections(U16 size)
Number of HttpConnection instances.
Definition: HttpServer.h:3433
BA_API int HttpResponse_printf(HttpResponse *o, const char *fmt,...)
printf is used for sending formatted data to the client.
BA_API char * HttpDir_makeAbsPath(HttpDir *o, const char *relPath, int relPathLen)
Makes an absolute path based on where the HttpDir instance is installed in the virtual file system an...
int sendBufAsError(int eCode)
Sends the data formatted into the HttpResponse buffer as an error message to the client.
Definition: HttpServer.h:2124
HttpSessionAttribute(const char *name, HttpSessionAttribute_Destructor terminate)
Create a session attribute.
Definition: HttpServer.h:2323
struct HttpDir HttpDir
An instance of the HttpDir class, which is a collection of zero or more resources,...
~HttpDir()
Unlink this directory and notify all child pages/directories through their service callbacks with NUL...
Definition: HttpServer.h:3159
struct HttpParameterIterator HttpParameterIterator
The HttpParameterIterator is used for iterating through the form elements parsed by the HttpServer ob...
BA_API void HttpServerConfig_constructor(HttpServerConfig *o)
The constructor sets up the default parameters.
uint16_t U16
Unsigned 16-bit integer.
Definition: GenPrimT.h:94
S32 SBaFileSize
Signed file-size value in bytes; 32 bits with BA_FILE_OFFSET_BITS=32.
Definition: GenPrimT.h:141
int32_t S32
Signed 32-bit integer.
Definition: GenPrimT.h:88
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:106
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:96
int16_t S16
Signed 16-bit integer.
Definition: GenPrimT.h:86
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:92
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:121
int8_t S8
Signed 8-bit integer.
Definition: GenPrimT.h:84
U32 BaFileSize
Unsigned file size or position in bytes; 32 bits with BA_FILE_OFFSET_BITS=32.
Definition: GenPrimT.h:139
Abstract base class implemented by BasicAuthUser, FormAuthUser and DigestAuthUser.
Definition: AuthenticatedUser.h:273
Abstract interface class implemented by DigestAuthenticator, FormAuthenticator and BasicAuthenticator...
Definition: AuthenticatedUser.h:426
An abstract class, which you must implement, provides a method of authorizing an authenticated user.
Definition: AuthenticatedUser.h:115
The BufPrint class, which implements a compact printf-style formatter, is a base class used by severa...
Definition: BufPrint.h:132
Abstract interface class for reading the "dat" file generated by HttpLink.
Definition: CspRunTm.h:126
Worker-pool dispatch interface borrowed by HttpServer.
Definition: HttpCmdThreadPoolIntf.h:63
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
Definition: HttpServer.h:2179
Contains information about the physical socket connection.
Definition: HttpConnection.h:80
A cookie is used for exchanging a small amount of information between a HttpPage and a web browser.
Definition: HttpServer.h:597
const char * getComment() const
Returns the comment set for this cookie or null if the cookie comment is not set.
Definition: HttpServer.h:605
const char * getPath() const
Returns the path on the server to which the browser returns this cookie.
Definition: HttpServer.h:629
BaTime getMaxAge() const
Read the stored cookie lifetime in seconds.
Definition: HttpServer.h:618
bool getSecure() const
Read the cookie's Secure flag.
Definition: HttpServer.h:635
const char * getDomain() const
Returns the domain name set for this cookie.
Definition: HttpServer.h:610
const char * getValue() const
Returns the value of the cookie.
Definition: HttpServer.h:646
bool getHttpOnly() const
Return the HttpOnly attribute.
Definition: HttpServer.h:641
const char * getName() const
Returns the name of the cookie.
Definition: HttpServer.h:623
An instance of the HttpDir class, which is a collection of zero or more resources,...
Definition: HttpServer.h:2824
HttpDir * getParent() const
Returns the parent directory or NULL if no parent.
Definition: HttpServer.h:2951
const char * getName() const
Returns the directory name.
Definition: HttpServer.h:2946
The web-server "Request Data" container.
Definition: HttpServer.h:285
const char * getBuf()
Get pointer to start of PUT/POST data.
Definition: HttpServer.h:321
S32 getBufSize()
Get the number of bytes currently available from getBuf().
Definition: HttpServer.h:323
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
Definition: HttpServer.h:2697
const char * getName() const
Returns the page name.
Definition: HttpServer.h:2721
The HttpParameterIterator is used for iterating through the form elements parsed by the HttpServer ob...
Definition: HttpServer.h:484
const char * getValue() const
Return the borrowed current value, or NULL at the end.
Definition: HttpServer.h:515
const char * getName() const
Return the borrowed current name, or NULL at the end.
Definition: HttpServer.h:511
A persistent container object for HTTP parameters.
Definition: HttpServer.h:387
static U32 calculateSize(struct HttpRequest *req)
Calculate the HttpParameter size.
Definition: HttpServer.h:446
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:450
static HttpParameter * clone(void *buf, struct HttpRequest *req)
Copy HTTP parameters to buf and return as a HttpParameter object.
Definition: HttpServer.h:448
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:981
This object is used when sending response messages back to the client.
Definition: HttpServer.h:1387
Use an instance of this class if you want to override the default web-server parameters.
Definition: HttpServer.h:3227
Route and process HTTP requests using a borrowed dispatcher.
Definition: HttpServer.h:3463
The interface to an HttpSession attribute.
Definition: HttpServer.h:2279
The HttpSession container class.
Definition: HttpServer.h:2581
Provides a way to identify a user across more than one page request or visit to a web site,...
Definition: HttpServer.h:2338
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:97
Intrusive tree node.
Definition: SplayTree.h:52
Self-adjusting tree of caller-owned nodes, with unique keys.
Definition: SplayTree.h:109
A mutual exclusion class.
Definition: ThreadLib.h:196
User database interface used by the authentication classes.
Definition: AuthenticatedUser.h:196