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;
25 /* the following two values start at 1 because the initial parent thread counts as one. */
26 int num_threads_existing = 1; /* Number of worker threads which exist. */
27 int num_threads_executing = 1; /* Number of worker threads currently executing. */
29 void DestroyHttpHeaderHandler(void *V)
32 pHdr = (OneHttpHeader*) V;
33 FreeStrBuf(&pHdr->Val);
37 void shutdown_sessions(void)
41 for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
46 void do_housekeeping(void)
49 wcsession *sessions_to_kill = NULL;
52 * Lock the session list, moving any candidates for euthanasia into
55 pthread_mutex_lock(&SessionListMutex);
56 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;
96 * Check the size of our thread pool. If all threads are executing, spawn another.
98 begin_critical_section(S_SPAWNER);
100 (num_threads_executing >= num_threads_existing)
101 && (num_threads_existing <= MAX_WORKER_THREADS)
103 spawn_another_worker_thread();
105 end_critical_section(S_SPAWNER);
110 * Wake up occasionally and clean house
112 void housekeeping_loop(void)
115 sleeeeeeeeeep(HOUSEKEEPING);
122 * Create a Session id
123 * Generate a unique WebCit session ID (which is not the same thing as the
124 * Citadel session ID).
126 int GenerateSessionID(void)
128 static int seq = (-1);
131 seq = (int) time(NULL);
137 wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
139 wcsession *sptr = NULL;
140 wcsession *TheSession = NULL;
142 if (Hdr->HR.got_auth == AUTH_BASIC) {
146 pthread_mutex_lock(ListMutex);
147 for (sptr = *wclist; ((sptr != NULL) && (TheSession == NULL)); sptr = sptr->next) {
149 /* If HTTP-AUTH, look for a session with matching credentials */
150 switch (Hdr->HR.got_auth)
153 if ( (Hdr->HR.SessionKey != sptr->SessionKey))
155 if ((!strcasecmp(ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username))) &&
156 (!strcasecmp(ChrPtr(Hdr->c_password), ChrPtr(sptr->wc_password))) ) {
159 if (TheSession == NULL)
160 lprintf(1, "found sessionkey [%ld], but credentials for [%s|%s] didn't match\n",
161 Hdr->HR.SessionKey,ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username));
164 /* If cookie-session, look for a session with matching session ID */
165 if ( (Hdr->HR.desired_session != 0) &&
166 (sptr->wc_session == Hdr->HR.desired_session)) {
174 pthread_mutex_unlock(ListMutex);
175 if (TheSession == NULL)
176 lprintf(1, "didn't find sessionkey [%ld] for user [%s]\n",
177 Hdr->HR.SessionKey,ChrPtr(Hdr->c_username));
181 wcsession *CreateSession(int Lockable, int Static, wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
183 wcsession *TheSession;
185 lprintf(3, "Creating a new session\n");
186 TheSession = (wcsession *) malloc(sizeof(wcsession));
187 memset(TheSession, 0, sizeof(wcsession));
188 TheSession->Hdr = Hdr;
189 TheSession->SessionKey = Hdr->HR.SessionKey;
190 TheSession->serv_sock = (-1);
191 TheSession->is_mobile = -1;
193 pthread_setspecific(MyConKey, (void *)TheSession);
195 /* If we're recreating a session that expired, it's best to give it the same
196 * session number that it had before. The client browser ought to pick up
197 * the new session number and start using it, but in some rare situations it
198 * doesn't, and that's a Bad Thing because it causes lots of spurious sessions
201 if (Hdr->HR.desired_session == 0) {
202 TheSession->wc_session = GenerateSessionID();
205 TheSession->wc_session = Hdr->HR.desired_session;
207 Hdr->HR.Static = Static;
208 session_new_modules(TheSession);
211 pthread_mutex_init(&TheSession->SessionMutex, NULL);
213 if (ListMutex != NULL)
214 pthread_mutex_lock(ListMutex);
216 if (wclist != NULL) {
217 TheSession->nonce = rand();
218 TheSession->next = *wclist;
219 *wclist = TheSession;
221 if (ListMutex != NULL)
222 pthread_mutex_unlock(ListMutex);
229 * Detects a 'mobile' user agent
231 int is_mobile_ua(char *user_agent) {
232 if (strstr(user_agent,"iPhone OS") != NULL) {
234 } else if (strstr(user_agent,"Windows CE") != NULL) {
236 } else if (strstr(user_agent,"SymbianOS") != NULL) {
238 } else if (strstr(user_agent, "Opera Mobi") != NULL) {
240 } else if (strstr(user_agent, "Firefox/2.0.0 Opera 9.51 Beta") != NULL) {
241 /* For some reason a new install of Opera 9.51beta decided to spoof. */
247 /* If it's a "force 404" situation then display the error and bail. */
250 hprintf("HTTP/1.1 404 Not found\r\n");
251 hprintf("Content-Type: text/plain\r\n");
252 wc_printf("Not found\r\n");
256 int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
259 void *vLine, *vHandler;
260 const char *Pos = NULL;
263 Hdr->HR.ReqLine = Line;
264 /* The requesttype... GET, POST... */
265 StrBufExtract_token(Buf, Hdr->HR.ReqLine, 0, ' ');
266 if (GetHash(HttpReqTypes, SKEY(Buf), &vLine) &&
269 Hdr->HR.eReqType = *(long*)vLine;
272 Hdr->HR.eReqType = eGET;
275 StrBufCutLeft(Hdr->HR.ReqLine, StrLength(Buf) + 1);
277 /* the HTTP Version... */
278 StrBufExtract_token(Buf, Hdr->HR.ReqLine, 1, ' ');
279 StrBufCutRight(Hdr->HR.ReqLine, StrLength(Buf) + 1);
281 if (StrLength(Buf) == 0) {
282 Hdr->HR.eReqType = eGET;
286 StrBufAppendBuf(Hdr->this_page, Hdr->HR.ReqLine, 0);
287 /* chop Filename / query arguments */
288 Args = strchr(ChrPtr(Hdr->HR.ReqLine), '?');
289 if (Args == NULL) /* whe're not that picky about params... TODO: this will spoil '&' in filenames.*/
290 Args = strchr(ChrPtr(Hdr->HR.ReqLine), '&');
292 Args ++; /* skip the ? */
293 StrBufPlain(Hdr->PlainArgs,
295 StrLength(Hdr->HR.ReqLine) -
296 (Args - ChrPtr(Hdr->HR.ReqLine)));
297 StrBufCutAt(Hdr->HR.ReqLine, 0, Args - 1);
298 } /* don't parse them yet, maybe we don't even care... */
300 /* now lookup what we are going to do with this... */
301 /* skip first slash */
302 StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
304 StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
306 GetHash(HandlerHash, SKEY(Buf), &vHandler),
307 Hdr->HR.Handler = (WebcitHandler*) vHandler;
308 if (Hdr->HR.Handler == NULL)
311 * If the request is prefixed by "/webcit" then chop that off. This
312 * allows a front end web server to forward all /webcit requests to us
313 * while still using the same web server port for other things.
315 if ((Hdr->HR.Handler->Flags & URLNAMESPACE) != 0)
319 /* remove the handlername from the URL */
320 if ((Pos != NULL) && (Pos != StrBufNOTNULL)){
321 StrBufCutLeft(Hdr->HR.ReqLine,
322 Pos - ChrPtr(Hdr->HR.ReqLine));
325 if (Hdr->HR.Handler != NULL) {
326 if ((Hdr->HR.Handler->Flags & BOGUS) != 0)
328 Hdr->HR.DontNeedAuth = (
329 ((Hdr->HR.Handler->Flags & ISSTATIC) != 0) ||
330 ((Hdr->HR.Handler->Flags & ANONYMOUS) != 0)
334 Hdr->HR.DontNeedAuth = 1; /* Flat request? show him the login screen... */
340 int AnalyseHeaders(ParsedHttpHdrs *Hdr)
346 HashPos *at = GetNewHashPos(Hdr->HTTPHeaders, 0);
348 while (GetNextHashPos(Hdr->HTTPHeaders, at, &HKLen, &HashKey, &vHdr) &&
350 pHdr = (OneHttpHeader *)vHdr;
351 if (pHdr->HaveEvaluator)
352 pHdr->H(pHdr->Val, Hdr);
359 /*const char *nix(void *vptr) {return ChrPtr( (StrBuf*)vptr);}*/
362 * Read in the request
364 int ReadHTTPRequest (ParsedHttpHdrs *Hdr)
366 const char *pch, *pchs, *pche;
368 StrBuf *Line, *LastLine, *HeaderName;
373 HeaderName = NewStrBuf();
377 Line = NewStrBufPlain(NULL, SIZ / 4);
379 if (ClientGetLine(Hdr, Line) < 0) return 1;
381 if (StrLength(Line) == 0) {
386 Hdr->HTTPHeaders = NewHash(1, NULL);
387 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
388 memset(pHdr, 0, sizeof(OneHttpHeader));
390 Put(Hdr->HTTPHeaders, HKEY("GET /"), pHdr, DestroyHttpHeaderHandler);
391 lprintf(9, "%s\n", ChrPtr(Line));
392 isbogus = ReadHttpSubject(Hdr, Line, HeaderName);
397 /* Do we need to Unfold? */
398 if ((LastLine != NULL) &&
399 (isspace(*ChrPtr(Line)))) {
400 pch = pchs = ChrPtr(Line);
401 pche = pchs + StrLength(Line);
402 while (isspace(*pch) && (pch < pche))
404 StrBufCutLeft(Line, pch - pchs);
405 StrBufAppendBuf(LastLine, Line, 0);
411 StrBufSanitizeAscii(Line, '§');
412 StrBufExtract_token(HeaderName, Line, 0, ':');
415 pche = pchs + StrLength(Line);
416 pch = pchs + StrLength(HeaderName) + 1;
417 pche = pchs + StrLength(Line);
418 while ((pch < pche) && isspace(*pch))
420 StrBufCutLeft(Line, pch - pchs);
422 StrBufUpCase(HeaderName);
424 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
425 memset(pHdr, 0, sizeof(OneHttpHeader));
428 if (GetHash(HttpHeaderHandler, SKEY(HeaderName), &vF) &&
431 OneHttpHeader *FHdr = (OneHttpHeader*) vF;
433 pHdr->HaveEvaluator = 1;
435 Put(Hdr->HTTPHeaders, SKEY(HeaderName), pHdr, DestroyHttpHeaderHandler);
437 } while (Line != NULL);
439 FreeStrBuf(&HeaderName);
444 void OverrideRequest(ParsedHttpHdrs *Hdr, const char *Line, long len)
446 StrBuf *Buf = NewStrBuf();
448 if (Hdr->HR.ReqLine != NULL) {
449 FlushStrBuf(Hdr->HR.ReqLine);
450 StrBufPlain(Hdr->HR.ReqLine, Line, len);
453 Hdr->HR.ReqLine = NewStrBufPlain(Line, len);
455 ReadHttpSubject(Hdr, Hdr->HR.ReqLine, Buf);
463 * This loop gets called once for every HTTP connection made to WebCit. At
464 * this entry point we have an HTTP socket with a browser allegedly on the
465 * other end, but we have not yet bound to a WebCit session.
467 * The job of this function is to locate the correct session and bind to it,
468 * or create a session if necessary and bind to it, then run the WebCit
469 * transaction loop. Afterwards, we unbind from the session. When this
470 * function returns, the worker thread is then free to handle another
473 void context_loop(ParsedHttpHdrs *Hdr)
476 wcsession *TheSession;
477 struct timeval tx_start;
478 struct timeval tx_finish;
480 gettimeofday(&tx_start, NULL); /* start a stopwatch for performance timing */
483 * Find out what it is that the web browser is asking for
485 isbogus = ReadHTTPRequest(Hdr);
487 Hdr->HR.dav_depth = 32767; /* TODO: find a general way to have non-0 defaults */
489 isbogus = AnalyseHeaders(Hdr);
492 ((Hdr->HR.Handler != NULL) &&
493 ((Hdr->HR.Handler->Flags & BOGUS) != 0)))
497 Bogus = CreateSession(0, 1, NULL, Hdr, NULL);
501 lprintf(9, "HTTP: 404 [%ld.%06ld] %s %s \n",
502 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
503 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
504 ReqStrs[Hdr->HR.eReqType],
505 ChrPtr(Hdr->this_page)
507 session_detach_modules(Bogus);
508 session_destroy_modules(&Bogus);
512 if ((Hdr->HR.Handler != NULL) && ((Hdr->HR.Handler->Flags & ISSTATIC) != 0))
515 Static = CreateSession(0, 1, NULL, Hdr, NULL);
517 Hdr->HR.Handler->F();
519 /* How long did this transaction take? */
520 gettimeofday(&tx_finish, NULL);
523 if ((Hdr->HR.Handler != NULL) ||
524 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
526 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
527 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
528 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
529 ReqStrs[Hdr->HR.eReqType],
530 ChrPtr(Hdr->this_page)
532 session_detach_modules(Static);
533 session_destroy_modules(&Static);
537 if (Hdr->HR.got_auth == AUTH_BASIC) {
542 * See if there's an existing session open with the desired ID or user/pass
544 TheSession = FindSession(&SessionList, Hdr, &SessionListMutex);
547 * Create a new session if we have to
549 if (TheSession == NULL) {
550 TheSession = CreateSession(1, 0, &SessionList, Hdr, &SessionListMutex);
552 if ((StrLength(Hdr->c_username) == 0) && (!Hdr->HR.DontNeedAuth)) {
554 if ((Hdr->HR.Handler != NULL) &&
555 (XHTTP_COMMANDS & Hdr->HR.Handler->Flags) == XHTTP_COMMANDS) {
556 OverrideRequest(Hdr, HKEY("GET /401 HTTP/1.0"));
557 Hdr->HR.prohibit_caching = 1;
560 OverrideRequest(Hdr, HKEY("GET /static/nocookies.html?force_close_session=yes HTTP/1.0"));
561 Hdr->HR.prohibit_caching = 1;
565 if (StrLength(Hdr->c_language) > 0) {
566 lprintf(9, "Session cookie requests language '%s'\n", ChrPtr(Hdr->c_language));
567 set_selected_language(ChrPtr(Hdr->c_language));
568 go_selected_language();
573 * A future improvement might be to check the session integrity
574 * at this point before continuing.
578 * Bind to the session and perform the transaction
580 pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
581 pthread_setspecific(MyConKey, (void *)TheSession);
583 TheSession->lastreq = time(NULL); /* log */
584 TheSession->Hdr = Hdr;
586 session_attach_modules(TheSession);
587 session_loop(); /* do transaction */
590 /* How long did this transaction take? */
591 gettimeofday(&tx_finish, NULL);
595 if ((Hdr->HR.Handler != NULL) &&
596 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
598 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
599 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
600 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
601 ReqStrs[Hdr->HR.eReqType],
602 ChrPtr(Hdr->this_page)
605 session_detach_modules(TheSession);
607 TheSession->Hdr = NULL;
608 pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */
611 void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
614 StrBufAppendPrintf(Target, "%ld",
615 (WCC != NULL)? WCC->nonce:0);
618 void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
620 StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
623 void Header_HandleContentLength(StrBuf *Line, ParsedHttpHdrs *hdr)
625 hdr->HR.ContentLength = StrToi(Line);
628 void Header_HandleContentType(StrBuf *Line, ParsedHttpHdrs *hdr)
630 hdr->HR.ContentType = Line;
633 void Header_HandleUserAgent(StrBuf *Line, ParsedHttpHdrs *hdr)
635 hdr->HR.user_agent = Line;
637 /* TODO: do this later on session creating
638 if ((WCC->is_mobile < 0) && is_mobile_ua(&buf[12])) {
649 void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
651 if ((follow_xff) && (hdr->HR.http_host != NULL))
654 hdr->HR.http_host = Line;
657 void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
660 hdr->HR.http_host = Line;
664 void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
666 hdr->HR.browser_host = Line;
668 while (StrBufNum_tokens(hdr->HR.browser_host, ',') > 1) {
669 StrBufRemove_token(hdr->HR.browser_host, 0, ',');
671 StrBufTrim(hdr->HR.browser_host);
674 void Header_HandleIfModSince(StrBuf *Line, ParsedHttpHdrs *hdr)
676 hdr->HR.if_modified_since = httpdate_to_timestamp(Line);
679 void Header_HandleAcceptEncoding(StrBuf *Line, ParsedHttpHdrs *hdr)
684 if (strstr(&ChrPtr(Line)[16], "gzip")) {
688 const char *ReqStrs[eNONE] = {
701 ServerStartModule_CONTEXT
705 HttpReqTypes = NewHash(1, NULL);
706 HttpHeaderHandler = NewHash(1, NULL);
708 v = malloc(sizeof(long));
710 Put(HttpReqTypes, HKEY("GET"), v, NULL);
712 v = malloc(sizeof(long));
714 Put(HttpReqTypes, HKEY("POST"), v, NULL);
716 v = malloc(sizeof(long));
718 Put(HttpReqTypes, HKEY("OPTIONS"), v, NULL);
720 v = malloc(sizeof(long));
722 Put(HttpReqTypes, HKEY("PROPFIND"), v, NULL);
724 v = malloc(sizeof(long));
726 Put(HttpReqTypes, HKEY("PUT"), v, NULL);
728 v = malloc(sizeof(long));
730 Put(HttpReqTypes, HKEY("DELETE"), v, NULL);
732 v = malloc(sizeof(long));
734 Put(HttpReqTypes, HKEY("HEAD"), v, NULL);
736 v = malloc(sizeof(long));
738 Put(HttpReqTypes, HKEY("MOVE"), v, NULL);
740 v = malloc(sizeof(long));
742 Put(HttpReqTypes, HKEY("COPY"), v, NULL);
746 ServerShutdownModule_CONTEXT
749 DeleteHash(&HttpReqTypes);
750 DeleteHash(&HttpHeaderHandler);
753 void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F)
756 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
757 memset(pHdr, 0, sizeof(OneHttpHeader));
759 Put(HttpHeaderHandler, Name, Len, pHdr, DestroyHttpHeaderHandler);
767 RegisterHeaderHandler(HKEY("CONTENT-LENGTH"), Header_HandleContentLength);
768 RegisterHeaderHandler(HKEY("CONTENT-TYPE"), Header_HandleContentType);
769 RegisterHeaderHandler(HKEY("USER-AGENT"), Header_HandleUserAgent);
770 RegisterHeaderHandler(HKEY("X-FORWARDED-HOST"), Header_HandleXFFHost); /* Apache way... */
771 RegisterHeaderHandler(HKEY("X-REAL-IP"), Header_HandleXFFHost); /* NGinX way... */
772 RegisterHeaderHandler(HKEY("HOST"), Header_HandleHost);
773 RegisterHeaderHandler(HKEY("X-FORWARDED-FOR"), Header_HandleXFF);
774 RegisterHeaderHandler(HKEY("ACCEPT-ENCODING"), Header_HandleAcceptEncoding);
775 RegisterHeaderHandler(HKEY("IF-MODIFIED-SINCE"), Header_HandleIfModSince);
777 RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, NULL, CTX_NONE);
778 RegisterNamespace("NONCE", 0, 0, tmplput_nonce, NULL, 0);
780 WebcitAddUrlHandler(HKEY("404"), "", 0, do_404, ANONYMOUS|COOKIEUNNEEDED);
782 * Look for commonly-found probes of malware such as worms, viruses, trojans, and Microsoft Office.
783 * Short-circuit these requests so we don't have to send them through the full processing loop.
785 WebcitAddUrlHandler(HKEY("scripts"), "", 0, do_404, ANONYMOUS|BOGUS); /* /root.exe - Worms and trojans and viruses, oh my! */
786 WebcitAddUrlHandler(HKEY("c"), "", 0, do_404, ANONYMOUS|BOGUS); /* /winnt */
787 WebcitAddUrlHandler(HKEY("MSADC"), "", 0, do_404, ANONYMOUS|BOGUS);
788 WebcitAddUrlHandler(HKEY("_vti"), "", 0, do_404, ANONYMOUS|BOGUS); /* Broken Microsoft DAV implementation */
789 WebcitAddUrlHandler(HKEY("MSOffice"), "", 0, do_404, ANONYMOUS|BOGUS); /* Stoopid MSOffice thinks everyone is IIS */
790 WebcitAddUrlHandler(HKEY("nonexistenshit"), "", 0, do_404, ANONYMOUS|BOGUS); /* Exploit found in the wild January 2009 */
795 HttpNewModule_CONTEXT
796 (ParsedHttpHdrs *httpreq)
798 httpreq->PlainArgs = NewStrBufPlain(NULL, SIZ);
799 httpreq->this_page = NewStrBufPlain(NULL, SIZ);
803 HttpDetachModule_CONTEXT
804 (ParsedHttpHdrs *httpreq)
806 FlushStrBuf(httpreq->PlainArgs);
807 FlushStrBuf(httpreq->this_page);
808 FlushStrBuf(httpreq->PlainArgs);
809 DeleteHash(&httpreq->HTTPHeaders);
810 memset(&httpreq->HR, 0, sizeof(HdrRefs));
814 HttpDestroyModule_CONTEXT
815 (ParsedHttpHdrs *httpreq)
817 FreeStrBuf(&httpreq->this_page);
818 FreeStrBuf(&httpreq->PlainArgs);
819 FreeStrBuf(&httpreq->this_page);
820 FreeStrBuf(&httpreq->PlainArgs);
821 DeleteHash(&httpreq->HTTPHeaders);