39#define BASLIB_VER "6057"
40#define BASLIB_VER_NO 6057
78#include "TargConfig.h"
80#include "DoubleList.h"
81#include "SingleList.h"
93#define BA_STACKSZ 24000
98#define BA_COOKIE_ID "z9ZAqJtI"
149#define httpUnescape(s) httpUnescapeInternal(s,FALSE)
155#define httpFormUnescape(s) httpUnescapeInternal(s,TRUE)
220typedef int (*ZlibInflateInit2)(
struct z_stream_s* s,
int windowBits,
221 const char *version,
int stream_size);
223typedef int (*ZlibInflate)(
struct z_stream_s* s,
int flush);
224typedef int (*ZlibInflateEnd)(
struct z_stream_s* s);
239typedef struct HttpHeader
252BA_API
const char* HttpHeader_name(HttpHeader* o,
struct HttpRequest* req);
253BA_API
const char* HttpHeader_value(HttpHeader* o,
struct HttpRequest* req);
256inline const char* HttpHeader::name(
HttpRequest* req) {
257 return HttpHeader_name(
this, req); }
258inline const char* HttpHeader::value(
HttpRequest* req) {
259 return HttpHeader_value(
this, req); }
278 HttpInData_ParseHeader,
280 HttpInData_ReadBodyAndParseUrlEncData
281} HttpInData_ParseState;
302 HttpAllocator allocator;
311#define HttpAllocator_2Ptr(o, index) ((&(o)->buf[index]))
312#define HttpInData_lineStartPtr(o) \
313 HttpAllocator_2Ptr(&(o)->allocator,(o)->lineStartI)
315#define HttpInData_getBufSize(o) \
316 ((o)->lineStartI < (o)->allocator.index ? \
317 (o)->allocator.index-(o)->lineStartI : 0)
319#define HttpInData_getBuf(o) HttpInData_lineStartPtr(o)
324 return HttpInData_getBuf(
this); }
326 return HttpInData_getBufSize(
this); }
542#define HttpParameterIterator_hasMoreElements(o) ((o)->name != 0)
543#define HttpParameterIterator_getName(o) (o)->name
544#define HttpParameterIterator_getValue(o) (o)->value
549inline HttpParameterIterator::HttpParameterIterator(
HttpRequest* req) {
554 HttpParameterIterator_nextElement(
this); }
615 bool getSecure()
const {
return secure ? true :
false; }
690 int getVersion()
const {
return version; }
692 void setVersion(
int v);
722BA_API
void HttpCookie_destructor(
HttpCookie* o);
767#define HttpCookie_deleteCookie(o) (o)->deleteCookieFlag = TRUE;
787void HttpCookie_setVersion(
HttpCookie* o,
int v);
796inline HttpCookie::HttpCookie() { baAssert(0); }
797inline HttpCookie::~HttpCookie() { HttpCookie_destructor(
this); }
805 HttpCookie_deleteCookie(
this); }
815inline void HttpCookie::setVersion(
int v) {
816 HttpCookie_setVersion(
this, v); }
864 U16 contentTypeHOffs;
870BA_API
const char* HttpStdHeaders_zzGetValFromOffs(
873#define HttpStdHeaders_getConnection(o) \
874 HttpStdHeaders_zzGetValFromOffs(o,(o)->connectionHOffs)
875#define HttpStdHeaders_getHost(o) \
876 HttpStdHeaders_zzGetValFromOffs(o,(o)->hostHOffs)
877#define HttpStdHeaders_getContentType(o) \
878 HttpStdHeaders_zzGetValFromOffs(o,(o)->contentTypeHOffs)
879#define HttpStdHeaders_getContentLength(o) (o)->contentLength
884 return HttpStdHeaders_getConnection(
this); }
886 return HttpStdHeaders_getHost(
this); }
888 return HttpStdHeaders_getDomain(
this); }
890 return HttpStdHeaders_getContentType(
this); }
892 return HttpStdHeaders_getContentLength(
this); }
911 HttpMethod_Connect =0x00001,
912 HttpMethod_Get =0x00002,
913 HttpMethod_Head =0x00004,
914 HttpMethod_Options =0x00008,
916 HttpMethod_Patch =0x00010,
917 HttpMethod_Post =0x00020,
918 HttpMethod_Put =0x00040,
919 HttpMethod_Trace =0x00080,
922 HttpMethod_Copy =0x00100,
923 HttpMethod_Delete =0x00200,
924 HttpMethod_Lock =0x00400,
925 HttpMethod_Move =0x00800,
927 HttpMethod_Mkcol =0x01000,
928 HttpMethod_Propfind =0x02000,
929 HttpMethod_Proppatch =0x04000,
930 HttpMethod_Unlock =0x08000,
932 HttpMethod_Unknown =0x10000
937BA_API
HttpMethod HttpMethod_a2m(
const char* str);
1177#ifndef NO_HTTP_SESSION
1200 int setUserObj(
void* userObj,
bool overwrite=
false);
1205 HttpAllocator headerAlloc;
1206 HttpAllocator formAlloc;
1219 BaBool expect100Continue;
1231BA_API
int HttpRequest_checkOptions(
1233#define HttpRequest_getAuthenticatedUser(o) \
1234 AuthenticatedUser_get2(HttpRequest_getSession(o,FALSE))
1235#define HttpRequest_getConnection(o) HttpRequest_getCommand(o)->con
1236#define HttpRequest_getMethodType(o) (o)->methodType
1237#define HttpRequest_getMethod(o) HttpRequest_getMethod2((o)->methodType)
1238BA_API
const char* HttpRequest_getMethod2(
HttpMethod method);
1239#define HttpRequest_getServer(o) (o)->server
1240#define HttpRequest_getResponse(o) (&HttpRequest_getCommand(o)->response)
1255#define HttpRequest_getStdHeaders(o) (&(o)->stdH)
1264#define HttpRequest_getNoOfParameters(o) (o)->formLen
1269#define HttpRequest_getUserObj(o) (o)->userObj
1270BA_API
int HttpRequest_setUserObj(
1272#define HttpRequest_getBuffer(o) (&(o)->inData)
1287BA_API
int HttpRequest_pushBackData(
HttpRequest* o);
1288#ifndef NO_HTTP_SESSION
1295 HttpRequest* o,
const char* val,
size_t len,
int set);
1301 U32 methods,
bool addDefault){
1303 methods, addDefault ? TRUE : FALSE);}
1308 return HttpRequest_getAuthenticatedUser(
this); }
1310 return HttpRequest_getMethodType(
this); }
1312 return HttpRequest_getMethod(
this); }
1314 return HttpRequest_getMethod2(method); }
1316 return HttpRequest_getServer(
this); }
1322 return HttpRequest_getStdHeaders(
this); }
1336inline int HttpRequest::setUserObj(
void* userObj,
bool overwrite) {
1337 return HttpRequest_setUserObj(
this, userObj, overwrite); }
1338inline void* HttpRequest::getUserObj() {
1339 return HttpRequest_getUserObj(
this); }
1340#ifndef NO_HTTP_SESSION
1345 return HttpParameterIterator_hasMoreElements(
this); }
1347 return HttpRequest_getBuffer(
this); }
1356 U16 maxResponseHeader;
1433 const char*
encodeUrl(
const char* path);
1467 int forward(
const char* path);
1516 int include(
const char* path);
1575 int sendError(
int eCode,
const char* msg);
1598 int fmtError(
int eCode,
const char* fmt, ...);
1691 int setHeader(
const char* name,
const char* value,
bool replace=
true);
1740 char*
fmtHeader(
const char* name,
int valueLen,
bool replace=
true);
1766 int printf(
const char* fmt, ...);
1791 int write(
const void* data,
int len,
int useBuffering=TRUE);
1800 int write(
const char* data,
int useBuffering=TRUE);
1812 int send(
const void* data,
int len);
1857 int setUserObj(
void* userObj,
bool overwrite=
false);
1859 NameValMM nameValMM;
1865 char* encodedRedirectURL;
1870 HttpProtocol protocol;
1874 char printAndWriteInitialized;
1875 char useChunkTransfer;
1893#define HttpResponse_byteCount(o) ((o)->msgLen + (o)->bodyPrint->cursor)
1899BA_API
const char* HttpResponse_encodeRedirectURLWithParamOrSessionURL(
1901#define HttpResponse_encodeRedirectURLWithParam(o, path) \
1902 HttpResponse_encodeRedirectURLWithParamOrSessionURL(o, path, FALSE)
1903#define HttpResponse_encodeSessionURL(o, path) \
1904 HttpResponse_encodeRedirectURLWithParamOrSessionURL(o, path, TRUE)
1916#define HttpResponse_forward(o,path) HttpResponse_incOrForward(o,path,FALSE)
1917#define HttpResponse_getConnection(o) HttpResponse_getCommand(o)->con
1918#define HttpResponse_getRequest(o) (&HttpResponse_getCommand(o)->request)
1920#define HttpResponse_getBuf(o) (o)->bodyPrint->buf
1921#define HttpResponse_getBufSize(o) (o)->bodyPrint->bufSize
1922#define HttpResponse_getBufOffs(o) \
1923 ((o)->bodyPrint->buf + (o)->bodyPrint->cursor)
1924#define HttpResponse_getRemBufSize(o) \
1925 ((o)->bodyPrint->bufSize - (o)->bodyPrint->cursor)
1926#define HttpResponse_getUserObj(o) (o)->userObj
1927BA_API
int HttpResponse_incOrForward(
1933#define HttpResponse_include(o,path) HttpResponse_incOrForward(o,path,TRUE)
1934#define HttpResponse_isChunkTransfer(o) (o)->useChunkTransfer
1935#define HttpResponse_committed(o) (o)->headerSent
1936#define HttpResponse_isForward(o) ((o)->forwardCounter != 0)
1937#define HttpResponse_isInclude(o) ((o)->includeCounter != 0)
1938#define HttpResponse_initial(o) (!HttpResponse_isForward(o) && \
1939 !HttpResponse_isInclude(o))
1958BA_API
int HttpResponse_sendError1(
HttpResponse* o,
int eCode);
1959BA_API
int HttpResponse_sendError2(
HttpResponse* o,
int eCode,
const char* msg);
1968BA_API
int HttpResponse_fmtVError(
1973BA_API
int HttpResponse_fmtError(
1976 const char* fmt, ...);
1981BA_API
int HttpResponse_sendRedirectI(
1987#define HttpResponse_forceHttps HttpResponse_redirect2TLS
1989#define HttpResponse_setBufPos(o, pos) (o)->bodyPrint->cursor = pos
1998BA_API
int HttpResponse_checkContentType(
HttpResponse* o,
const char* type);
2022BA_API
int HttpResponse_setStatus(
HttpResponse* o,
int eCode);
2023BA_API
int HttpResponse_vprintf(
2047BA_API
int HttpResponse_setUserObj(
2049BA_API
int HttpResponse_printAndWriteInit(
HttpResponse* o);
2050BA_API
int HttpResponse_send100Continue(
HttpResponse* o);
2051BA_API
int HttpResponse_setChunkEncoding(
HttpResponse* o);
2052BA_API
const char* HttpResponse_getRespData(
HttpResponse* o,
int* len);
2053#define HttpResponse_getStatus(o) (o)->statusCode
2061 return HttpResponse_byteCount(
this); }
2065 return HttpResponse_encodeRedirectURLWithParam(
this, p); }
2071 return HttpResponse_forward(
this, path); }
2075 return HttpResponse_include(
this, path); }
2077 return HttpResponse_committed(
this) ? true :
false; }
2079 return HttpResponse_isForward(
this) ? true :
false; }
2081 return HttpResponse_isInclude(
this) ? true :
false; }
2083 return HttpResponse_initial(
this) ? true :
false; }
2093 return HttpResponse_sendError1(
this, eCode); }
2095 return HttpResponse_sendError2(
this, eCode, msg); }
2101 int retv; va_list varg;
2102 va_start(varg, fmt);
2103 retv = HttpResponse_fmtVError(
this, eCode, fmt, varg);
2117 const char* name,
const char* value,
bool replace) {
2122 const char* name,
int valueLen,
bool replace) {
2125 HttpResponse_setStatus(
this, eCode);}
2128 int retv; va_list varg; va_start(varg, fmt);
2129 retv = HttpResponse_vprintf(
this, fmt, varg); va_end(varg);
return retv;}
2140inline int HttpResponse::setUserObj(
void* userObj,
bool overwrite) {
2141 return HttpResponse_setUserObj(
this, userObj, overwrite); }
2179 struct LHttpCommand* lcmd;
2184#define HttpCommand_getRequest(o) (&(o)->request)
2185#define HttpCommand_getResponse(o) (&(o)->response)
2186#define HttpCommand_getConnection(o) (o)->con
2187#define HttpCommand_getServer(o) HttpConnection_getServer((o)->con)
2190 return HttpCommand_getRequest(
this); }
2192 return HttpCommand_getResponse(
this); }
2194 return HttpCommand_getConnection(
this); }
2196 return HttpCommand_getServer(
this);
2201#ifndef NO_HTTP_SESSION
2287#define HttpSessionAttribute_getSession(o) (o)->session
2295 return HttpSessionAttribute_getSession(
this); }
2309 void operator delete(
void* d) {
if(d)
::baFree(d); }
2310 void *
operator new(size_t,
void *place) {
return place; }
2311 void operator delete(
void*,
void *) { }
2408 void incrementLock();
2409 void decrementLock();
2421 BaTime maxInactiveInterval;
2473#define HttpSession_incrRefCntr(o) (o)->refCounter++
2478#define HttpSession_incrementLock(o) (o)->lockCounter++
2479#define HttpSession_decrementLock(o) do {\
2480 baAssert((o)->lockCounter > 0);\
2481 (o)->lockCounter--; } while(0)
2489#define HttpSession_getId(o) \
2490 ((U32)((ptrdiff_t)SplayTreeNode_getKey((SplayTreeNode*)(o))))
2491#define HttpSession_getAuthenticatedUser(o) AuthenticatedUser_get2((o))
2492#define HttpSession_getUseCounter(o) (o)->useCounter
2493#define HttpSession_getPeerName(o) (&(o)->peer)
2515 HttpSession_incrRefCntr(
this); }
2520 return HttpSession_getUseCounter(
this); }
2522 return HttpSession_getAuthenticatedUser(
this); }
2523inline void HttpSession::incrementLock() {HttpSession_incrementLock(
this);}
2524inline void HttpSession::decrementLock() {HttpSession_decrementLock(
this);}
2529 HttpSessionContainer_OK = 0,
2530 HttpSessionContainer_NoMemory,
2531 HttpSessionContainer_TooManySessions,
2532 HttpSessionContainer_NoPeerAddress
2533} HttpSessionContainer_ECode;
2552 DoubleList sessionList;
2553 DoubleList sessionTermList;
2554 DoubleLink* sessionLinkIter;
2558 HttpSessionContainer_ECode eCode;
2569#define HttpSessionContainer_setMaxSessions(o,max) (o)->maxSessions = max
2573 HttpSessionContainer_setMaxSessions(
this, max); }
2594#define HttpPageType_HttpPageSE 0x00020
2597typedef struct HttpPageNode
2599 struct HttpPageNode* next;
2659 void operator delete(
void* d) {
if(d)
::baFree(d); }
2660 void *
operator new(size_t,
void *place) {
return place; }
2661 void operator delete(
void*,
void *) { }
2714#define HttpPage_getName(o) (o)->name
2715#define HttpPage_isLinked(o) ((HttpPageNode*)(o))->next
2720#define HttpPage_service(o, request, response) \
2721 (o)->serviceCB(o, request, response)
2729 return HttpPage_isLinked(
this) ? true :
false;
2733 HttpPage_service(
this, request, response);
2748 const char* relPath,
2751#define HttpDirType_EhDir 0x00001
2752#define HttpDirType_HttpResRdr 0x00002
2753#define HttpDirType_AuthenticateDir 0x00008
2754#define HttpDirType_AuthenticateDirWrapper 0x00010
2780 void operator delete(
void* d) {
if(d)
::baFree(d); }
2781 void *
operator new(size_t,
void *place) {
return place; }
2782 void operator delete(
void*,
void *) { }
2804 HttpDir(
const char* name,
S8 priority=0);
2876 unsigned int nameLen);
2923 char*
makeAbsPath(
const char* relPath,
int relPathLen);
3014 HttpPageNode pageList;
3034 HttpDir* o,
const char* relPath,
int relPathLen);
3035#define HttpDir_getRootPath(o) HttpDir_makeAbsPath(o,"",0)
3040#define HttpDir_getFirstPage(o) \
3041 (o)->pageList.next != &(o)->pageList ? ((HttpPage*)(o)->pageList.next) : 0
3042#define HttpDir_getFirstDir(o) (o)->dirList
3051#define HttpDir_getNext(o) (o)->next
3052#define HttpDir_getName(o) (o)->name
3053#define HttpDir_getParent(o) (o)->parent
3067 HttpDir* iter,
const char* name,
unsigned int nameLen);
3076#define HttpDir_overloadService HttpDir_setService
3081#define HttpDir_isLinked(o) (o)->parent
3086#define HttpDir_setAuthenticator(o,authenticatorMA,authorizerMA) \
3087 (o)->authenticator = authenticatorMA,(o)->realm = authorizerMA
3093#define HttpDir_isAuthorized(o,user,method,path) \
3095 (user ? AuthorizerIntf_authorize((o)->realm,user,method,path) : FALSE) : \
3108 return HttpDir_getRootPath(
this); }
3123 unsigned int nameLen) {
3133 return HttpDir_isLinked(
this) ? true :
false; }
3136 HttpDir_setAuthenticator(
this,authenticator,authorizer);
3145typedef struct HttpLinkCon
3157 BaBool page404InProgress;
3317 U16 minResponseHeader;
3318 U16 maxResponseHeader;
3321 U16 noOfHttpCommands;
3322 U16 noOfHttpConnections;
3385typedef DoubleList HttpLinkConList;
3388typedef void (*LspOnTerminateRequest)(
struct LHttpCommand* lcmd);
3396 void operator delete(
void* d) {
if(d)
::baFree(d); }
3397 void *
operator new(size_t,
void *place) {
return place; }
3398 void operator delete(
void*,
void *) { }
3503 const char* virtualDirRootPath,
3506 struct AuthUserList* getAuthUserList(
const char* name);
3524#ifndef NO_HTTP_SESSION
3552 int setUserObj(
void* userObj,
bool overwrite=
false);
3571 static void setErrHnd(UserDefinedErrHandler e);
3574 static int setZlib(ZlibInflateInit2 init,
3575 ZlibInflate inflate,
3576 ZlibInflateEnd end){
3577 (void)init; (void)inflate; (void)end;
3588 DoubleList commandPool;
3589 DoubleList cmdReqList;
3591 HttpLinkConList freeList;
3592 HttpLinkConList readyList;
3593 HttpLinkConList connectedList;
3594 HttpRootDir rootDirContainer;
3597 HttpLinkCon* connections;
3600 SingleList waitForConClose;
3601 LspOnTerminateRequest lspOnTerminateRequest;
3602 int commandPoolSize;
3603 U16 noOfConnections;
3604 S16 maxHttpRequestLen;
3605#ifndef NO_HTTP_SESSION
3612void HttpServer_AsynchProcessDir(
HttpServer* o,
3616#define HttpServer_setThreadPoolIntf(o, intf) (o)->threadPoolIntf=intf
3617#define HttpServer_luaenv(o) (o)->luaenv
3641 const char* virtualDirRootPath,
3648 const char* virtualDirRootPath,
3650#define HttpServer_getAuthUserList(o, name) \
3651 (AuthUserList*)SplayTree_find(&(o)->authUserTree, name)
3652#define HttpServer_getDispatcher(o) (o)->dispatcher
3653#define HttpServer_getFirstRootDir(o) \
3654 HttpDir_getFirstDir((HttpDir*)&(o)->rootDirContainer)
3655#define HttpServer_getUserObj(o) (o)->userObj
3656#define HttpServer_getSessionContainer(o) (&(o)->sessionContainer)
3657#define HttpServer_getMutex(o) SoDisp_getMutex((o)->dispatcher)
3663void HttpServer_doLingeringClose(
3666#ifndef NO_HTTP_SESSION
3677BA_API
void HttpServer_setErrHnd(UserDefinedErrHandler e);
3678void HttpServer_initStatic(
void);
3679int HttpServer_termOldestIdleCon(
HttpServer* o);
3684#define HttpServer_get404Page(o) (o)->rootDirContainer.page404
3685BA_API
int HttpServer_setUserObj(
3687#define HttpServer_termAllSessions(o) \
3688 HttpSessionContainer_destructor(&(o)->sessionContainer)
3690#define HttpServer_setZlib(init,inflate,end);
3700 return HttpServer_getMutex(
this);
3705 const char* virtualDirRootPath,
3708inline struct AuthUserList* HttpServer::getAuthUserList(
const char* name) {
3709 return HttpServer_getAuthUserList(
this,name); }
3711 return HttpServer_getDispatcher(
this); }
3713 return HttpServer_getFirstRootDir(
this); }
3715 return HttpServer_getSessionContainer(
this); }
3716#ifndef NO_HTTP_SESSION
3720 HttpServer_initStatic(); }
3722 HttpServer_setErrHnd(e); }
3726 return HttpServer_get404Page(
this); }
3727inline int HttpServer::setUserObj(
void* userObj,
bool overwrite) {
3728 return HttpServer_setUserObj(
this, userObj, overwrite); }
3736 return HttpRequest_getResponse(
this); }
3738 return HttpRequest_getConnection(
this); }
3740 return HttpResponse_getRequest(
this); }
3742 return HttpResponse_getCommand(
this); }
3744 return HttpRequest_getCommand(
this); }
3755#define SHARKSSL_MD5_HASH_LEN 16
3756#define SHARKSSL_SHA1_HASH_LEN 20
3758typedef struct SharkSslMd5Ctx
3765SHARKSSL_API
void SharkSslMd5Ctx_constructor(SharkSslMd5Ctx* ctx);
3766SHARKSSL_API
void SharkSslMd5Ctx_append(SharkSslMd5Ctx* ctx,
const U8* data,
U32 len);
3767SHARKSSL_API
void SharkSslMd5Ctx_finish(SharkSslMd5Ctx* ctx,
U8 digest[]);
3768SHARKSSL_API
int sharkssl_md5(
const U8*,
U16,
U8*);
3770typedef struct SharkSslSha1Ctx
3777SHARKSSL_API
void SharkSslSha1Ctx_constructor(SharkSslSha1Ctx* ctx);
3778SHARKSSL_API
void SharkSslSha1Ctx_append(SharkSslSha1Ctx* ctx,
const U8* data,
U32 len);
3779SHARKSSL_API
void SharkSslSha1Ctx_finish(SharkSslSha1Ctx*,
U8 digest[]);
3781typedef 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:212
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:2500
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:804
HttpHeader * getHeaders(int *len)
Return an HTTP header iterator that can iterate and fetch all the HTTP headers.
Definition: HttpServer.h:1334
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:2074
BaTime getCreationTime()
Returns the time when this session was created, measured in seconds since midnight January 1,...
Definition: HttpServer.h:2498
int setMaxAge(BaTime seconds)
Sets header "Cache-Control: max-age=seconds".
Definition: HttpServer.h:2119
int setDateHeader(const char *name, BaTime time)
Sets a response header with the given name and date-value.
Definition: HttpServer.h:2114
HttpDir * getNext()
Returns the next dir in the parent list.
Definition: HttpServer.h:3119
const char * getRequestURI()
Returns the pathname.
Definition: HttpServer.h:1317
const char * containsHeader(const char *name)
Searches the internal response header database for a header with the specified name.
Definition: HttpServer.h:2058
const char * getContentType()
Returns the content type, for example: "application/x-www-form-urlencoded".
Definition: HttpServer.h:889
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()
Returns the host header.
Definition: HttpServer.h:885
BA_API BaTime HttpCookie_getMaxAge(HttpCookie *o)
Returns the maximum age of the cookie, specified in seconds; by default, 0 indicating the cookie will...
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:2068
void(* HttpSessionAttribute_Destructor)(struct HttpSessionAttribute *o)
HttpSessionAttribute termination callback function.
Definition: HttpServer.h:2216
int sendError(int eCode)
Sends an error response as a simple HTML page to the client using the specified status code.
Definition: HttpServer.h:2092
int forward(const char *path)
Forwards a request from a servlet to another resource (servlet, CSP file, or HTML file).
Definition: HttpServer.h:2070
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:810
int setContentLength(BaFileSize len)
Sets the "Content-Length" parameter value.
Definition: HttpServer.h:2110
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:808
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:3120
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:1315
int resetHeaders()
Removes all HTTP headers.
Definition: HttpServer.h:2088
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:2195
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:2189
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:3111
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:2510
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:1309
int send(const void *data, int len)
Used when sending raw data to the client.
Definition: HttpServer.h:2136
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:2191
int removeResponseBuf()
Remove buffer set by using setResponseBuf.
Definition: HttpServer.h:2086
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:910
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:3737
const char * getDomain()
Returns the host header without any port number.
Definition: HttpServer.h:887
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:3134
struct HttpConnection * getConnection()
Get the current connection object that the HttpCommand instance is bound with.
Definition: HttpServer.h:2193
int sendBufAsTxtError(int eCode)
Sends the data formatted into the HttpResponse buffer as an error message to the client.
Definition: HttpServer.h:2098
bool isForward() const
Returns true if this is a forward request from another servlet or CSP file.
Definition: HttpServer.h:2078
AuthenticatedUser * getAuthenticatedUser()
Returns the authenticated user or NULL if user is not authenticated.
Definition: HttpServer.h:1307
int unlink()
Unlinks/removes the page from the parent directory.
Definition: HttpServer.h:2731
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:2504
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:3367
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:1344
HttpStdHeaders * getStdHeaders()
Returns an object containing standard HTTP headers.
Definition: HttpServer.h:1321
const char * getHeaderValue(const char *name)
Returns the value of the specified request header.
Definition: HttpServer.h:1325
int setDefaultHeaders()
Sets the most common header values in servlet and CSP files.
Definition: HttpServer.h:2138
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:2090
int insertCSP(CspInit cspInit, const char *virtualDirRootPath, struct CspReader *reader)
Insert and initialize a CSP Virtual Directory.
Definition: HttpServer.h:3704
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:2062
bool initial() const
Returns true if this is the initial page.
Definition: HttpServer.h:2082
~HttpServer()
Stop using the server before destruction.
Definition: HttpServer.h:3695
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:3721
void terminate()
Unbinds any objects bound to this session object, runs the HttpSession destructor,...
Definition: HttpServer.h:2506
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:2726
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:553
SBaFileSize getContentLength()
Returns the content length if request contains a body.
Definition: HttpServer.h:891
U32 byteCount()
Returns number of bytes sent thus far.
Definition: HttpServer.h:2060
int setCommit(U16 size)
Set the size of the HTTP response commit buffer.
Definition: HttpServer.h:3373
BA_API BaBool HttpCookie_getSecure(HttpCookie *o)
Returns true if the browser is sending cookies only over a secure protocol, or false if the browser c...
HttpDir()
Constructor for creating a root dir, a root dir has no name.
Definition: HttpServer.h:3099
struct HttpServer HttpServer
The Web Server.
int setValue(const char *newValue)
Assigns a new value to a cookie after the cookie is created.
Definition: HttpServer.h:812
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:1327
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:3699
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:2732
void setMaxAge(BaTime expiry)
Sets the maximum age of the cookie in seconds.
Definition: HttpServer.h:802
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:2084
HttpSessionContainer * getSessionContainer()
Get the HttpSessionContainer.
Definition: HttpServer.h:3714
HttpDir * getFirstRootDir()
Returns the first root directory.
Definition: HttpServer.h:3712
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:2496
AuthenticatedUser * getAuthenticatedUser()
Returns the AuthenticatedUser if user is authenticated.
Definition: HttpServer.h:2521
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:2112
void(* HttpPage_Service)(struct HttpPage *page, HttpRequest *request, HttpResponse *response)
The HttpPage service function.
Definition: HttpServer.h:2589
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:2518
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:3369
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:3723
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:2064
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:3719
BA_API int HttpResponse_resetHeaders(HttpResponse *o)
Removes all HTTP headers.
struct HttpServer * getServer()
Definition: HttpServer.h:3745
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:2132
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:2134
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:3379
HttpInData * getBuffer()
Get the internal rec buffer.
Definition: HttpServer.h:1346
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)
Encodes an absolute or relative URL, or if encoding is not needed, returns the URL unchanged.
Definition: HttpServer.h:2066
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:3375
HttpDir * createOrGet(const char *name)
Returns a sub-directory with the given name.
Definition: HttpServer.h:3125
bool authenticateAndAuthorize(HttpCommand *cmd, const char *path)
Authenticate and authorize the user.
Definition: HttpServer.h:3138
int(* HttpDir_Service)(struct HttpDir *o, const char *relPath, HttpCommand *cmd)
The HttpDir service callback function.
Definition: HttpServer.h:2747
HttpServer(SoDisp *dispatcher, HttpServerConfig *cfg=0)
Create a Web Server object.
Definition: HttpServer.h:3693
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:2121
bool isInclude() const
Returns true if this is an include from another servlet or CSP file.
Definition: HttpServer.h:2080
int unlink()
Unlinks/removes the directory from the parent directory.
Definition: HttpServer.h:3131
char * getRootPath()
Calculates the root of where the HttpDir instance is installed in the virtual file system.
Definition: HttpServer.h:3107
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)
Checks the HTTP method type and sends a response message if condition met.
Definition: HttpServer.h:1300
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:1323
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:2127
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:2108
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)
Encodes an absolute or relative URL, or if encoding is not needed, returns the URL unchanged.
BA_API int HttpPage_unlink(HttpPage *o)
Unlinks/removes the page from the parent directory.
HttpPage * getFirstPage()
Returns the first page.
Definition: HttpServer.h:3113
SoDisp * getDispatcher()
Returns the dispatcher object.
Definition: HttpServer.h:3710
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:3115
int wsUpgrade()
Validate and send an HTTP/1.1 WebSocket version-13 handshake.
Definition: HttpServer.h:1331
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)
Checks the HTTP method type and sends a response message if condition met.
static const char * getStatusCode(int code)
Return a short description for common HTTP error codes.
Definition: HttpServer.h:3729
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:3105
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:3717
U32 getUseCounter()
Get the session usage counter.
Definition: HttpServer.h:2519
bool committed() const
Returns a boolean indicating if the response has been committed.
Definition: HttpServer.h:2076
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:2072
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:2514
const char * getConnection()
Returns the connection type for HTTP 1.1 connections, returns "Close" or "Keep-Alive.
Definition: HttpServer.h:883
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:1329
void decrRefCntr()
Decrements the session reference counter.
Definition: HttpServer.h:2516
const char * getRequestURL(bool forceHttps=false)
Reconstructs the URL the client used to make the request.
Definition: HttpServer.h:1319
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:3743
int insertDir(HttpDir *dir)
Insert a sub-directory.
Definition: HttpServer.h:3109
void setMaxInactiveInterval(BaTime interval)
Specifies the time, in seconds, between client requests before the session container will invalidate ...
Definition: HttpServer.h:2512
void setMaxSessions(int max)
Set the maximum number of session objects.
Definition: HttpServer.h:2572
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:2728
const char * get404Page()
Returns a pointer to the current 404 page, if any.
Definition: HttpServer.h:3725
HttpCommand * getCommand()
Get the HttpCommand object.
Definition: HttpServer.h:3741
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:3122
int setPath(const char *uri)
Set the cookie path.
Definition: HttpServer.h:806
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:1341
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:3365
const char * getMethod()
Returns a string representation of the value returned by HttpRequest::getMethodType.
Definition: HttpServer.h:1311
BaTime getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the session container will keep this session open...
Definition: HttpServer.h:2502
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:2056
HttpPage * getPage(const char *name)
Returns the page with the name given or NULL if not found.
Definition: HttpServer.h:3117
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:798
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:2100
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:3127
HttpDir * getFirstDir()
Returns the first sub-directory.
Definition: HttpServer.h:3114
int setDomain(const char *pattern)
Specifies the domain within which this cookie should be presented.
Definition: HttpServer.h:800
bool isLinked()
Returns true if this directory node is installed into a parent directory.
Definition: HttpServer.h:3132
HttpResponse * getResponse()
Returns the HttpResponse object.
Definition: HttpServer.h:3735
int insertDir(const char *virtualDirRootPath, HttpDir *dir)
Insert a directory node into the virtual file system.
Definition: HttpServer.h:3702
void setStatus(int statusCode)
Sets the status code for this response.
Definition: HttpServer.h:2124
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:3697
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:2116
HttpRequest * getRequest()
Get the HttpRequest object.
Definition: HttpServer.h:3739
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:3129
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:2294
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:1305
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:818
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:2106
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:3371
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:2508
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:3377
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:2096
HttpSessionAttribute(const char *name, HttpSessionAttribute_Destructor terminate)
Create a session attribute.
Definition: HttpServer.h:2290
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:3103
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:91
S32 SBaFileSize
Signed file-size value in bytes; 32 bits without BA_FILESIZE64.
Definition: GenPrimT.h:138
int32_t S32
Signed 32-bit integer.
Definition: GenPrimT.h:85
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:103
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
int16_t S16
Signed 16-bit integer.
Definition: GenPrimT.h:83
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:89
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
int8_t S8
Signed 8-bit integer.
Definition: GenPrimT.h:81
U32 BaFileSize
Unsigned file size or position in bytes; 32 bits without BA_FILESIZE64.
Definition: GenPrimT.h:136
Abstract base class implemented by BasicAuthUser, FormAuthUser and DigestAuthUser.
Definition: AuthenticatedUser.h:272
Abstract interface class implemented by DigestAuthenticator, FormAuthenticator and BasicAuthenticator...
Definition: AuthenticatedUser.h:425
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:2151
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:589
const char * getComment() const
Returns the comment set for this cookie or null if the cookie comment is not set.
Definition: HttpServer.h:595
const char * getPath() const
Returns the path on the server to which the browser returns this cookie.
Definition: HttpServer.h:610
BaTime getMaxAge() const
Returns the maximum age of the cookie, specified in seconds; by default, 0 indicating the cookie will...
Definition: HttpServer.h:603
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:615
const char * getDomain() const
Returns the domain name set for this cookie.
Definition: HttpServer.h:598
const char * getValue() const
Returns the value of the cookie.
Definition: HttpServer.h:623
bool getHttpOnly() const
Return the HttpOnly attribute.
Definition: HttpServer.h:620
const char * getName() const
Returns the name of the cookie.
Definition: HttpServer.h:606
An instance of the HttpDir class, which is a collection of zero or more resources,...
Definition: HttpServer.h:2777
HttpDir * getParent() const
Returns the parent directory or NULL if no parent.
Definition: HttpServer.h:2897
const char * getName() const
Returns the directory name.
Definition: HttpServer.h:2893
The web-server "Request Data" container.
Definition: HttpServer.h:288
const char * getBuf()
Get pointer to start of PUT/POST data.
Definition: HttpServer.h:323
S32 getBufSize()
Get size of internal buffer.
Definition: HttpServer.h:325
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
Definition: HttpServer.h:2656
const char * getName() const
Returns the page name.
Definition: HttpServer.h:2679
The HttpParameterIterator is used for iterating through the form elements parsed by the HttpServer ob...
Definition: HttpServer.h:485
const char * getValue() const
Return the borrowed current value, or NULL at the end.
Definition: HttpServer.h:507
const char * getName() const
Return the borrowed current name, or NULL at the end.
Definition: HttpServer.h:505
A persistent container object for HTTP parameters.
Definition: HttpServer.h:389
static U32 calculateSize(struct HttpRequest *req)
Calculate the HttpParameter size.
Definition: HttpServer.h:448
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:452
static HttpParameter * clone(void *buf, struct HttpRequest *req)
Copy HTTP parameters to buf and return as a HttpParameter object.
Definition: HttpServer.h:450
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:950
This object is used when sending response messages back to the client.
Definition: HttpServer.h:1379
Use an instance of this class if you want to override the default web-server parameters.
Definition: HttpServer.h:3171
The Web Server.
Definition: HttpServer.h:3393
The interface to an HttpSession attribute.
Definition: HttpServer.h:2247
The HttpSession container class.
Definition: HttpServer.h:2540
Provides a way to identify a user across more than one page request or visit to a web site,...
Definition: HttpServer.h:2305
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:91
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:195