4 * This is the other half of the webserver. It handles the task of hooking
5 * up HTTP requests with the sessions they belong to, using HTTP cookies to
6 * keep track of things. If the HTTP request doesn't belong to any currently
7 * active session, a new session is started.
12 #include "webserver.h"
13 #include "modules_init.h"
15 /* Only one thread may manipulate SessionList at a time... */
16 pthread_mutex_t SessionListMutex;
18 wcsession *SessionList = NULL; /* Linked list of all webcit sessions */
20 pthread_key_t MyConKey; /* TSD key for MySession() */
21 HashList *HttpReqTypes = NULL;
22 HashList *HttpHeaderHandler = NULL;
23 extern HashList *HandlerHash;
24 int num_threads = 1; /* Number of worker threads. Start at 1 because the parent counts. */
26 void DestroyHttpHeaderHandler(void *V)
29 pHdr = (OneHttpHeader*) V;
30 FreeStrBuf(&pHdr->Val);
34 void shutdown_sessions(void)
38 for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
43 void do_housekeeping(void)
46 wcsession *sessions_to_kill = NULL;
50 * Lock the session list, moving any candidates for euthanasia into
53 pthread_mutex_lock(&SessionListMutex);
55 for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
58 /* Kill idle sessions */
59 if ((time(NULL) - (sptr->lastreq)) > (time_t) WEBCIT_TIMEOUT) {
63 /* Remove sessions flagged for kill */
66 /** remove session from linked list */
67 if (sptr == SessionList) {
68 SessionList = SessionList->next;
70 else for (ss=SessionList;ss!=NULL;ss=ss->next) {
71 if (ss->next == sptr) {
72 ss->next = ss->next->next;
76 sptr->next = sessions_to_kill;
77 sessions_to_kill = sptr;
80 pthread_mutex_unlock(&SessionListMutex);
83 * Now free up and destroy the culled sessions.
85 while (sessions_to_kill != NULL) {
86 lprintf(3, "Destroying session %d\n", sessions_to_kill->wc_session);
87 pthread_mutex_lock(&sessions_to_kill->SessionMutex);
88 pthread_mutex_unlock(&sessions_to_kill->SessionMutex);
89 sptr = sessions_to_kill->next;
91 session_destroy_modules(&sessions_to_kill);
92 sessions_to_kill = sptr;
97 * If there are more sessions than threads, then we should spawn
98 * more threads ... up to a predefined maximum.
100 while ( (num_sessions > num_threads) && (num_threads <= MAX_WORKER_THREADS) ) {
101 spawn_another_worker_thread();
102 lprintf(3, "There are %d sessions and %d threads active.\n",
103 num_sessions, num_threads);
109 * Wake up occasionally and clean house
111 void housekeeping_loop(void)
114 sleeeeeeeeeep(HOUSEKEEPING);
121 * Create a Session id
122 * Generate a unique WebCit session ID (which is not the same thing as the
123 * Citadel session ID).
125 int GenerateSessionID(void)
127 static int seq = (-1);
130 seq = (int) time(NULL);
136 wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
138 wcsession *sptr = NULL;
139 wcsession *TheSession = NULL;
141 if (Hdr->HR.got_auth == AUTH_BASIC) {
145 pthread_mutex_lock(ListMutex);
146 for (sptr = *wclist; ((sptr != NULL) && (TheSession == NULL)); sptr = sptr->next) {
148 /* If HTTP-AUTH, look for a session with matching credentials */
149 switch (Hdr->HR.got_auth)
152 if ( (Hdr->HR.SessionKey != sptr->SessionKey))
154 if ((!strcasecmp(ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username))) &&
155 (!strcasecmp(ChrPtr(Hdr->c_password), ChrPtr(sptr->wc_password))) ) {
158 if (TheSession == NULL)
159 lprintf(1, "found sessionkey [%ld], but credentials for [%s|%s] didn't match\n",
160 Hdr->HR.SessionKey,ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username));
163 /* If cookie-session, look for a session with matching session ID */
164 if ( (Hdr->HR.desired_session != 0) &&
165 (sptr->wc_session == Hdr->HR.desired_session)) {
173 pthread_mutex_unlock(ListMutex);
174 if (TheSession == NULL)
175 lprintf(1, "didn't find sessionkey [%ld] for user [%s]\n",
176 Hdr->HR.SessionKey,ChrPtr(Hdr->c_username));
180 wcsession *CreateSession(int Lockable, int Static, wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
182 wcsession *TheSession;
184 lprintf(3, "Creating a new session\n");
185 TheSession = (wcsession *) malloc(sizeof(wcsession));
186 memset(TheSession, 0, sizeof(wcsession));
187 TheSession->Hdr = Hdr;
188 TheSession->SessionKey = Hdr->HR.SessionKey;
189 TheSession->serv_sock = (-1);
190 TheSession->is_mobile = -1;
192 pthread_setspecific(MyConKey, (void *)TheSession);
194 /* If we're recreating a session that expired, it's best to give it the same
195 * session number that it had before. The client browser ought to pick up
196 * the new session number and start using it, but in some rare situations it
197 * doesn't, and that's a Bad Thing because it causes lots of spurious sessions
200 if (Hdr->HR.desired_session == 0) {
201 TheSession->wc_session = GenerateSessionID();
204 TheSession->wc_session = Hdr->HR.desired_session;
206 Hdr->HR.Static = Static;
207 session_new_modules(TheSession);
210 pthread_mutex_init(&TheSession->SessionMutex, NULL);
212 if (ListMutex != NULL)
213 pthread_mutex_lock(ListMutex);
215 if (wclist != NULL) {
216 TheSession->nonce = rand();
217 TheSession->next = *wclist;
218 *wclist = TheSession;
220 if (ListMutex != NULL)
221 pthread_mutex_unlock(ListMutex);
228 * Detects a 'mobile' user agent
230 int is_mobile_ua(char *user_agent) {
231 if (strstr(user_agent,"iPhone OS") != NULL) {
233 } else if (strstr(user_agent,"Windows CE") != NULL) {
235 } else if (strstr(user_agent,"SymbianOS") != NULL) {
237 } else if (strstr(user_agent, "Opera Mobi") != NULL) {
239 } else if (strstr(user_agent, "Firefox/2.0.0 Opera 9.51 Beta") != NULL) {
240 /* For some reason a new install of Opera 9.51beta decided to spoof. */
246 /* If it's a "force 404" situation then display the error and bail. */
249 hprintf("HTTP/1.1 404 Not found\r\n");
250 hprintf("Content-Type: text/plain\r\n");
251 wc_printf("Not found\r\n");
255 int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
258 void *vLine, *vHandler;
259 const char *Pos = NULL;
262 Hdr->HR.ReqLine = Line;
263 /* The requesttype... GET, POST... */
264 StrBufExtract_token(Buf, Hdr->HR.ReqLine, 0, ' ');
265 if (GetHash(HttpReqTypes, SKEY(Buf), &vLine) &&
268 Hdr->HR.eReqType = *(long*)vLine;
271 Hdr->HR.eReqType = eGET;
274 StrBufCutLeft(Hdr->HR.ReqLine, StrLength(Buf) + 1);
276 /* the HTTP Version... */
277 StrBufExtract_token(Buf, Hdr->HR.ReqLine, 1, ' ');
278 StrBufCutRight(Hdr->HR.ReqLine, StrLength(Buf) + 1);
280 if (StrLength(Buf) == 0) {
281 Hdr->HR.eReqType = eGET;
285 StrBufAppendBuf(Hdr->this_page, Hdr->HR.ReqLine, 0);
286 /* chop Filename / query arguments */
287 Args = strchr(ChrPtr(Hdr->HR.ReqLine), '?');
288 if (Args == NULL) /* whe're not that picky about params... TODO: this will spoil '&' in filenames.*/
289 Args = strchr(ChrPtr(Hdr->HR.ReqLine), '&');
291 Args ++; /* skip the ? */
292 StrBufPlain(Hdr->PlainArgs,
294 StrLength(Hdr->HR.ReqLine) -
295 (Args - ChrPtr(Hdr->HR.ReqLine)));
296 StrBufCutAt(Hdr->HR.ReqLine, 0, Args - 1);
297 } /* don't parse them yet, maybe we don't even care... */
299 /* now lookup what we are going to do with this... */
300 /* skip first slash */
301 StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
303 StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
305 GetHash(HandlerHash, SKEY(Buf), &vHandler),
306 Hdr->HR.Handler = (WebcitHandler*) vHandler;
307 if (Hdr->HR.Handler == NULL)
310 * If the request is prefixed by "/webcit" then chop that off. This
311 * allows a front end web server to forward all /webcit requests to us
312 * while still using the same web server port for other things.
314 if ((Hdr->HR.Handler->Flags & URLNAMESPACE) != 0)
318 /* remove the handlername from the URL */
319 if ((Pos != NULL) && (Pos != StrBufNOTNULL)){
320 StrBufCutLeft(Hdr->HR.ReqLine,
321 Pos - ChrPtr(Hdr->HR.ReqLine));
324 if (Hdr->HR.Handler != NULL) {
325 if ((Hdr->HR.Handler->Flags & BOGUS) != 0)
327 Hdr->HR.DontNeedAuth = (
328 ((Hdr->HR.Handler->Flags & ISSTATIC) != 0) ||
329 ((Hdr->HR.Handler->Flags & ANONYMOUS) != 0)
333 Hdr->HR.DontNeedAuth = 1; /* Flat request? show him the login screen... */
339 int AnalyseHeaders(ParsedHttpHdrs *Hdr)
345 HashPos *at = GetNewHashPos(Hdr->HTTPHeaders, 0);
347 while (GetNextHashPos(Hdr->HTTPHeaders, at, &HKLen, &HashKey, &vHdr) &&
349 pHdr = (OneHttpHeader *)vHdr;
350 if (pHdr->HaveEvaluator)
351 pHdr->H(pHdr->Val, Hdr);
358 /*const char *nix(void *vptr) {return ChrPtr( (StrBuf*)vptr);}*/
361 * Read in the request
363 int ReadHTTPRequest (ParsedHttpHdrs *Hdr)
365 const char *pch, *pchs, *pche;
367 StrBuf *Line, *LastLine, *HeaderName;
372 HeaderName = NewStrBuf();
376 Line = NewStrBufPlain(NULL, SIZ / 4);
378 if (ClientGetLine(Hdr, Line) < 0) return 1;
380 if (StrLength(Line) == 0) {
385 Hdr->HTTPHeaders = NewHash(1, NULL);
386 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
387 memset(pHdr, 0, sizeof(OneHttpHeader));
389 Put(Hdr->HTTPHeaders, HKEY("GET /"), pHdr, DestroyHttpHeaderHandler);
390 lprintf(9, "%s\n", ChrPtr(Line));
391 isbogus = ReadHttpSubject(Hdr, Line, HeaderName);
396 /* Do we need to Unfold? */
397 if ((LastLine != NULL) &&
398 (isspace(*ChrPtr(Line)))) {
399 pch = pchs = ChrPtr(Line);
400 pche = pchs + StrLength(Line);
401 while (isspace(*pch) && (pch < pche))
403 StrBufCutLeft(Line, pch - pchs);
404 StrBufAppendBuf(LastLine, Line, 0);
410 StrBufSanitizeAscii(Line, '§');
411 StrBufExtract_token(HeaderName, Line, 0, ':');
414 pche = pchs + StrLength(Line);
415 pch = pchs + StrLength(HeaderName) + 1;
416 pche = pchs + StrLength(Line);
417 while ((pch < pche) && isspace(*pch))
419 StrBufCutLeft(Line, pch - pchs);
421 StrBufUpCase(HeaderName);
423 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
424 memset(pHdr, 0, sizeof(OneHttpHeader));
427 if (GetHash(HttpHeaderHandler, SKEY(HeaderName), &vF) &&
430 OneHttpHeader *FHdr = (OneHttpHeader*) vF;
432 pHdr->HaveEvaluator = 1;
434 Put(Hdr->HTTPHeaders, SKEY(HeaderName), pHdr, DestroyHttpHeaderHandler);
436 } while (Line != NULL);
438 FreeStrBuf(&HeaderName);
443 void OverrideRequest(ParsedHttpHdrs *Hdr, const char *Line, long len)
445 StrBuf *Buf = NewStrBuf();
447 if (Hdr->HR.ReqLine != NULL) {
448 FlushStrBuf(Hdr->HR.ReqLine);
449 StrBufPlain(Hdr->HR.ReqLine, Line, len);
452 Hdr->HR.ReqLine = NewStrBufPlain(Line, len);
454 ReadHttpSubject(Hdr, Hdr->HR.ReqLine, Buf);
462 * This loop gets called once for every HTTP connection made to WebCit. At
463 * this entry point we have an HTTP socket with a browser allegedly on the
464 * other end, but we have not yet bound to a WebCit session.
466 * The job of this function is to locate the correct session and bind to it,
467 * or create a session if necessary and bind to it, then run the WebCit
468 * transaction loop. Afterwards, we unbind from the session. When this
469 * function returns, the worker thread is then free to handle another
472 void context_loop(ParsedHttpHdrs *Hdr)
475 wcsession *TheSession;
476 struct timeval tx_start;
477 struct timeval tx_finish;
479 gettimeofday(&tx_start, NULL); /* start a stopwatch for performance timing */
482 * Find out what it is that the web browser is asking for
484 isbogus = ReadHTTPRequest(Hdr);
486 Hdr->HR.dav_depth = 32767; /* TODO: find a general way to have non-0 defaults */
488 isbogus = AnalyseHeaders(Hdr);
491 ((Hdr->HR.Handler != NULL) &&
492 ((Hdr->HR.Handler->Flags & BOGUS) != 0)))
496 Bogus = CreateSession(0, 1, NULL, Hdr, NULL);
500 lprintf(9, "HTTP: 404 [%ld.%06ld] %s %s \n",
501 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
502 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
503 ReqStrs[Hdr->HR.eReqType],
504 ChrPtr(Hdr->this_page)
506 session_detach_modules(Bogus);
507 session_destroy_modules(&Bogus);
511 if ((Hdr->HR.Handler != NULL) && ((Hdr->HR.Handler->Flags & ISSTATIC) != 0))
514 Static = CreateSession(0, 1, NULL, Hdr, NULL);
516 Hdr->HR.Handler->F();
518 /* How long did this transaction take? */
519 gettimeofday(&tx_finish, NULL);
522 if ((Hdr->HR.Handler != NULL) ||
523 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
525 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
526 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
527 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
528 ReqStrs[Hdr->HR.eReqType],
529 ChrPtr(Hdr->this_page)
531 session_detach_modules(Static);
532 session_destroy_modules(&Static);
536 if (Hdr->HR.got_auth == AUTH_BASIC) {
541 * See if there's an existing session open with the desired ID or user/pass
543 TheSession = FindSession(&SessionList, Hdr, &SessionListMutex);
546 * Create a new session if we have to
548 if (TheSession == NULL) {
549 TheSession = CreateSession(1, 0, &SessionList, Hdr, &SessionListMutex);
551 if ((StrLength(Hdr->c_username) == 0) && (!Hdr->HR.DontNeedAuth)) {
553 if ((Hdr->HR.Handler != NULL) &&
554 (XHTTP_COMMANDS & Hdr->HR.Handler->Flags) == XHTTP_COMMANDS) {
555 OverrideRequest(Hdr, HKEY("GET /401 HTTP/1.0"));
556 Hdr->HR.prohibit_caching = 1;
559 OverrideRequest(Hdr, HKEY("GET /static/nocookies.html?force_close_session=yes HTTP/1.0"));
560 Hdr->HR.prohibit_caching = 1;
564 if (StrLength(Hdr->c_language) > 0) {
565 lprintf(9, "Session cookie requests language '%s'\n", ChrPtr(Hdr->c_language));
566 set_selected_language(ChrPtr(Hdr->c_language));
567 go_selected_language();
572 * A future improvement might be to check the session integrity
573 * at this point before continuing.
577 * Bind to the session and perform the transaction
579 pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
580 pthread_setspecific(MyConKey, (void *)TheSession);
582 TheSession->lastreq = time(NULL); /* log */
583 TheSession->Hdr = Hdr;
585 session_attach_modules(TheSession);
586 session_loop(); /* do transaction */
589 /* How long did this transaction take? */
590 gettimeofday(&tx_finish, NULL);
594 if ((Hdr->HR.Handler != NULL) &&
595 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
597 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
598 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
599 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
600 ReqStrs[Hdr->HR.eReqType],
601 ChrPtr(Hdr->this_page)
604 session_detach_modules(TheSession);
606 TheSession->Hdr = NULL;
607 pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */
610 void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
613 StrBufAppendPrintf(Target, "%ld",
614 (WCC != NULL)? WCC->nonce:0);
617 void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
619 StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
622 void Header_HandleContentLength(StrBuf *Line, ParsedHttpHdrs *hdr)
624 hdr->HR.ContentLength = StrToi(Line);
627 void Header_HandleContentType(StrBuf *Line, ParsedHttpHdrs *hdr)
629 hdr->HR.ContentType = Line;
632 void Header_HandleUserAgent(StrBuf *Line, ParsedHttpHdrs *hdr)
634 hdr->HR.user_agent = Line;
636 /* TODO: do this later on session creating
637 if ((WCC->is_mobile < 0) && is_mobile_ua(&buf[12])) {
648 void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
650 if ((follow_xff) && (hdr->HR.http_host != NULL))
653 hdr->HR.http_host = Line;
656 void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
659 hdr->HR.http_host = Line;
663 void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
665 hdr->HR.browser_host = Line;
667 while (StrBufNum_tokens(hdr->HR.browser_host, ',') > 1) {
668 StrBufRemove_token(hdr->HR.browser_host, 0, ',');
670 StrBufTrim(hdr->HR.browser_host);
673 void Header_HandleIfModSince(StrBuf *Line, ParsedHttpHdrs *hdr)
675 hdr->HR.if_modified_since = httpdate_to_timestamp(Line);
678 void Header_HandleAcceptEncoding(StrBuf *Line, ParsedHttpHdrs *hdr)
683 if (strstr(&ChrPtr(Line)[16], "gzip")) {
687 const char *ReqStrs[eNONE] = {
700 ServerStartModule_CONTEXT
704 HttpReqTypes = NewHash(1, NULL);
705 HttpHeaderHandler = NewHash(1, NULL);
707 v = malloc(sizeof(long));
709 Put(HttpReqTypes, HKEY("GET"), v, NULL);
711 v = malloc(sizeof(long));
713 Put(HttpReqTypes, HKEY("POST"), v, NULL);
715 v = malloc(sizeof(long));
717 Put(HttpReqTypes, HKEY("OPTIONS"), v, NULL);
719 v = malloc(sizeof(long));
721 Put(HttpReqTypes, HKEY("PROPFIND"), v, NULL);
723 v = malloc(sizeof(long));
725 Put(HttpReqTypes, HKEY("PUT"), v, NULL);
727 v = malloc(sizeof(long));
729 Put(HttpReqTypes, HKEY("DELETE"), v, NULL);
731 v = malloc(sizeof(long));
733 Put(HttpReqTypes, HKEY("HEAD"), v, NULL);
735 v = malloc(sizeof(long));
737 Put(HttpReqTypes, HKEY("MOVE"), v, NULL);
739 v = malloc(sizeof(long));
741 Put(HttpReqTypes, HKEY("COPY"), v, NULL);
745 ServerShutdownModule_CONTEXT
748 DeleteHash(&HttpReqTypes);
749 DeleteHash(&HttpHeaderHandler);
752 void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F)
755 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
756 memset(pHdr, 0, sizeof(OneHttpHeader));
758 Put(HttpHeaderHandler, Name, Len, pHdr, DestroyHttpHeaderHandler);
766 RegisterHeaderHandler(HKEY("CONTENT-LENGTH"), Header_HandleContentLength);
767 RegisterHeaderHandler(HKEY("CONTENT-TYPE"), Header_HandleContentType);
768 RegisterHeaderHandler(HKEY("USER-AGENT"), Header_HandleUserAgent);
769 RegisterHeaderHandler(HKEY("X-FORWARDED-HOST"), Header_HandleXFFHost); /* Apache way... */
770 RegisterHeaderHandler(HKEY("X-REAL-IP"), Header_HandleXFFHost); /* NGinX way... */
771 RegisterHeaderHandler(HKEY("HOST"), Header_HandleHost);
772 RegisterHeaderHandler(HKEY("X-FORWARDED-FOR"), Header_HandleXFF);
773 RegisterHeaderHandler(HKEY("ACCEPT-ENCODING"), Header_HandleAcceptEncoding);
774 RegisterHeaderHandler(HKEY("IF-MODIFIED-SINCE"), Header_HandleIfModSince);
776 RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, NULL, CTX_NONE);
777 RegisterNamespace("NONCE", 0, 0, tmplput_nonce, NULL, 0);
779 WebcitAddUrlHandler(HKEY("404"), "", 0, do_404, ANONYMOUS|COOKIEUNNEEDED);
781 * Look for commonly-found probes of malware such as worms, viruses, trojans, and Microsoft Office.
782 * Short-circuit these requests so we don't have to send them through the full processing loop.
784 WebcitAddUrlHandler(HKEY("scripts"), "", 0, do_404, ANONYMOUS|BOGUS); /* /root.exe - Worms and trojans and viruses, oh my! */
785 WebcitAddUrlHandler(HKEY("c"), "", 0, do_404, ANONYMOUS|BOGUS); /* /winnt */
786 WebcitAddUrlHandler(HKEY("MSADC"), "", 0, do_404, ANONYMOUS|BOGUS);
787 WebcitAddUrlHandler(HKEY("_vti"), "", 0, do_404, ANONYMOUS|BOGUS); /* Broken Microsoft DAV implementation */
788 WebcitAddUrlHandler(HKEY("MSOffice"), "", 0, do_404, ANONYMOUS|BOGUS); /* Stoopid MSOffice thinks everyone is IIS */
789 WebcitAddUrlHandler(HKEY("nonexistenshit"), "", 0, do_404, ANONYMOUS|BOGUS); /* Exploit found in the wild January 2009 */
794 HttpNewModule_CONTEXT
795 (ParsedHttpHdrs *httpreq)
797 httpreq->PlainArgs = NewStrBufPlain(NULL, SIZ);
798 httpreq->this_page = NewStrBufPlain(NULL, SIZ);
802 HttpDetachModule_CONTEXT
803 (ParsedHttpHdrs *httpreq)
805 FlushStrBuf(httpreq->PlainArgs);
806 FlushStrBuf(httpreq->this_page);
807 FlushStrBuf(httpreq->PlainArgs);
808 DeleteHash(&httpreq->HTTPHeaders);
809 memset(&httpreq->HR, 0, sizeof(HdrRefs));
813 HttpDestroyModule_CONTEXT
814 (ParsedHttpHdrs *httpreq)
816 FreeStrBuf(&httpreq->this_page);
817 FreeStrBuf(&httpreq->PlainArgs);
818 FreeStrBuf(&httpreq->this_page);
819 FreeStrBuf(&httpreq->PlainArgs);
820 DeleteHash(&httpreq->HTTPHeaders);