19 const int CONFIG_ACCESS_GROUP =99;
65 void ProcessLine(PSTR startofline);
66 int Respond(
int socket);
67 bool ExtractAuthentication(
char **pPassword,
char **pUser);
68 } __attribute__((packed));
76 } __attribute__((packed));
78 typedef int(http_wshandler)(HTTP_Request *req,
int sock, PSTR url, PSTR rxb);
82 eTCP_CONN_OPEN_NO_DATA,
83 eTCP_CONN_OPEN_TO_LONG,
93 HtmlPageHandler *m_pNextHandler;
94 const char *m_pUrlName;
97 void InsertSort(HtmlPageHandler *&ph);
98 int SortValue(HtmlPageHandler *pv);
100 virtual bool Match(HTTP_Request &req);
109 HtmlPageHandler(
const char *url,
HTTP_RequestTypes rt =
tGet,
int accessGroup = 0,
bool Before_Files =
false);
112 static HtmlPageHandler *FindHandler(HTTP_Request &req,
bool bBeforeFiles);
116 virtual int ProcessRaw(
int sock, HTTP_Request &pd) = 0;
118 inline int GetGroup() {
return m_access_group; };
121 typedef int(http_gethandlerfunc)(
int sock, HTTP_Request &pd);
122 typedef bool(http_matchhandlerfunc)(HTTP_Request &pd);
138 class CallBackFunctionPageHandler :
public HtmlPageHandler
141 http_gethandlerfunc *m_pf;
142 http_matchhandlerfunc *m_mhf;
145 inline virtual int ProcessRaw(
int sock, HTTP_Request &pdt) {
return m_pf(sock, pdt); };
162 http_gethandlerfunc *pFunction,
165 bool beforeFiles =
false)
166 : HtmlPageHandler(pUrl, reqType, accessGroup, beforeFiles), m_pf(pFunction)
171 inline CallBackFunctionPageHandler(
const char *pUrl,
172 http_gethandlerfunc *pFunction,
173 http_matchhandlerfunc *pMatchFunction,
176 bool beforeFiles =
false)
177 : HtmlPageHandler(pUrl, reqType, accessGroup, beforeFiles), m_pf(pFunction)
179 m_mhf = pMatchFunction;
182 virtual bool Match(HTTP_Request &req)
187 return HtmlPageHandler::Match(req);
198 HTTP_RESPONSE_HANDLED
201 extern const char *pHttpRealm;
216 HTTP_ACCESS
CheckHttpAccess(
int sock,
int accessGroup, HTTP_Request &Req);
232 typedef int(http_errorhandler)(
IPADDR ip,
enum eWEB_ERROR Err,
void *prm);
233 typedef int(http_wshandler)(HTTP_Request *req,
int sock, PSTR url, PSTR rxb);
236 http_errorhandler *SetNewErrorHandler(http_errorhandler *newhandler);
239 http_wshandler *SetNewWSHandler(http_wshandler *newhandler);
373 void writesafestring(
int fd, PCSTR str);
390 int decodeURI(
char *str);
416 void append(
char *&cpto,
const char *cpfrm);
PSTR pURL
Request URL.
Definition: http.h:50
void StopHttp()
Stop the HTTP web server.
Definition: httpinternal.cpp:350
PSTR pData
Pointer to entire data set. Note: not null terminated.
Definition: http.h:53
uint16_t sep_len
Length of separator for multipart forms.
Definition: http.h:58
PSTR pSep
Separator for multipart forms, null if not present.
Definition: http.h:54
void ForbiddenResponse(int sock, PCSTR url)
Send a page is forbidden response.
Definition: httpinternal.cpp:477
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition: ipv6_addr.h:28
void NotAvailableResponse(int sock, PCSTR url)
Send a response indicating that the requested resource is not available at this time.
Definition: httpinternal.cpp:487
GET request.
Definition: http.h:31
void SendTextHeader(int sock)
Send a HTML plain text header.
Definition: httpinternal.cpp:273
HTTP_ACCESS CheckHttpAccess(int sock, int accessGroup, HTTP_Request &Req)
All HTTP requests go though this function.
Definition: http_weak_auth.cpp:5
CallBackFunctionPageHandler(const char *pUrl, http_gethandlerfunc *pFunction, HTTP_RequestTypes reqType=tGet, int accessGroup=0, bool beforeFiles=false)
Constructor for HTTP GET callback function.
Definition: http.h:161
uint8_t websocketFlags
Web socket flags.
Definition: http.h:62
PSTR pAuthorization
Authorization header if present, otherwise null.
Definition: http.h:51
Header request, does not include content.
Definition: http.h:33
PSTR wsKey
Web socket ket, internal use only.
Definition: http.h:56
uint32_t rx_length
Total bytes receive from request, internal use only.
Definition: http.h:60
void BadRequestResponse(int sock, PCSTR url, PCSTR data)
Send a response indicating that the client request itself is faulty in some manner.
Definition: httpinternal.cpp:497
PSTR wsProtocol
Web socket prototocl, internal use only.
Definition: http.h:57
PSTR pFirstCookie
First cookie if present, othewise null. More may follow.
Definition: http.h:52
void RedirectResponse(int sock, PCSTR new_page)
Redirect a HTTP request to a different page.
Definition: httpinternal.cpp:462
void SendHTMLHeaderWCookie(int sock, char *cookie)
Send a HTML response header and cookie.
Definition: httpinternal.cpp:266
int httpstricmp(PCSTR str1, PCSTR strIsUpper2)
Special string compare. Returns 1 if the strings match until one string ends with a null (0)...
Definition: httpstricmp.cpp:10
void StartHttp(uint16_t port)
Start the HTTP web server. Further documentation in the Initialization section Initialization - Syste...
Definition: http.cpp:296
void SendHTMLHeader(int sock)
Send a HTML response header.
Definition: httpinternal.cpp:261
HTTP_RequestTypes
Definition: http.h:28
The type of request in not yet known.
Definition: http.h:30
PSTR last_datarx
Pointer to last data read, internal use only.
Definition: http.h:55
HTTP_RequestTypes req
Type of request HTTP Request Types.
Definition: http.h:63
uint32_t content_length
Content length field from HTML header.
Definition: http.h:59
int writeallsafestring(int fd, PCSTR str)
Send a string and escape all special characters.
Definition: httpinternal.cpp:388
void SendGifHeader(int sock)
Send a HTML GIF header.
Definition: httpinternal.cpp:278
void NotFoundResponse(int sock, PCSTR new_page)
Send a page not found response.
Definition: httpinternal.cpp:469
POST request.
Definition: http.h:32
IPADDR client_IPaddr
IP address of client.
Definition: http.h:61