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->chat_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 FlushStrBuf(Hdr->HR.ReqLine);
449 StrBufPlain(Hdr->HR.ReqLine, Line, len);
450 ReadHttpSubject(Hdr, Hdr->HR.ReqLine, Buf);
458 * This loop gets called once for every HTTP connection made to WebCit. At
459 * this entry point we have an HTTP socket with a browser allegedly on the
460 * other end, but we have not yet bound to a WebCit session.
462 * The job of this function is to locate the correct session and bind to it,
463 * or create a session if necessary and bind to it, then run the WebCit
464 * transaction loop. Afterwards, we unbind from the session. When this
465 * function returns, the worker thread is then free to handle another
468 void context_loop(ParsedHttpHdrs *Hdr)
471 wcsession *TheSession;
472 struct timeval tx_start;
473 struct timeval tx_finish;
475 gettimeofday(&tx_start, NULL); /* start a stopwatch for performance timing */
478 * Find out what it is that the web browser is asking for
480 isbogus = ReadHTTPRequest(Hdr);
482 Hdr->HR.dav_depth = 32767; /* TODO: find a general way to have non-0 defaults */
484 isbogus = AnalyseHeaders(Hdr);
487 ((Hdr->HR.Handler != NULL) &&
488 ((Hdr->HR.Handler->Flags & BOGUS) != 0)))
492 Bogus = CreateSession(0, 1, NULL, Hdr, NULL);
496 lprintf(9, "HTTP: 404 [%ld.%06ld] %s %s \n",
497 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
498 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
499 ReqStrs[Hdr->HR.eReqType],
500 ChrPtr(Hdr->this_page)
502 session_detach_modules(Bogus);
503 session_destroy_modules(&Bogus);
507 if ((Hdr->HR.Handler != NULL) && ((Hdr->HR.Handler->Flags & ISSTATIC) != 0))
510 Static = CreateSession(0, 1, NULL, Hdr, NULL);
512 Hdr->HR.Handler->F();
514 /* How long did this transaction take? */
515 gettimeofday(&tx_finish, NULL);
518 if ((Hdr->HR.Handler != NULL) ||
519 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
521 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
522 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
523 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
524 ReqStrs[Hdr->HR.eReqType],
525 ChrPtr(Hdr->this_page)
527 session_detach_modules(Static);
528 session_destroy_modules(&Static);
532 if (Hdr->HR.got_auth == AUTH_BASIC) {
537 * See if there's an existing session open with the desired ID or user/pass
539 TheSession = FindSession(&SessionList, Hdr, &SessionListMutex);
542 * Create a new session if we have to
544 if (TheSession == NULL) {
545 TheSession = CreateSession(1, 0, &SessionList, Hdr, &SessionListMutex);
547 if ((StrLength(Hdr->c_username) == 0) && (!Hdr->HR.DontNeedAuth)) {
549 if ((Hdr->HR.Handler != NULL) &&
550 (XHTTP_COMMANDS & Hdr->HR.Handler->Flags) == XHTTP_COMMANDS) {
551 OverrideRequest(Hdr, HKEY("GET /401 HTTP/1.0"));
552 Hdr->HR.prohibit_caching = 1;
555 OverrideRequest(Hdr, HKEY("GET /static/nocookies.html?force_close_session=yes HTTP/1.0"));
556 Hdr->HR.prohibit_caching = 1;
560 if (StrLength(Hdr->c_language) > 0) {
561 lprintf(9, "Session cookie requests language '%s'\n", ChrPtr(Hdr->c_language));
562 set_selected_language(ChrPtr(Hdr->c_language));
563 go_selected_language();
568 * A future improvement might be to check the session integrity
569 * at this point before continuing.
573 * Bind to the session and perform the transaction
575 pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
576 pthread_setspecific(MyConKey, (void *)TheSession);
578 TheSession->lastreq = time(NULL); /* log */
579 TheSession->Hdr = Hdr;
581 session_attach_modules(TheSession);
582 session_loop(); /* do transaction */
585 /* How long did this transaction take? */
586 gettimeofday(&tx_finish, NULL);
590 if ((Hdr->HR.Handler != NULL) &&
591 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
593 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
594 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
595 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
596 ReqStrs[Hdr->HR.eReqType],
597 ChrPtr(Hdr->this_page)
600 session_detach_modules(TheSession);
602 TheSession->Hdr = NULL;
603 pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */
606 void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
609 StrBufAppendPrintf(Target, "%ld",
610 (WCC != NULL)? WCC->nonce:0);
613 void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
615 StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
618 void Header_HandleContentLength(StrBuf *Line, ParsedHttpHdrs *hdr)
620 hdr->HR.ContentLength = StrToi(Line);
623 void Header_HandleContentType(StrBuf *Line, ParsedHttpHdrs *hdr)
625 hdr->HR.ContentType = Line;
628 void Header_HandleUserAgent(StrBuf *Line, ParsedHttpHdrs *hdr)
630 hdr->HR.user_agent = Line;
632 /* TODO: do this later on session creating
633 if ((WCC->is_mobile < 0) && is_mobile_ua(&buf[12])) {
644 void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
646 if ((follow_xff) && (hdr->HR.http_host != NULL))
649 hdr->HR.http_host = Line;
652 void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
655 hdr->HR.http_host = Line;
659 void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
661 hdr->HR.browser_host = Line;
663 while (StrBufNum_tokens(hdr->HR.browser_host, ',') > 1) {
664 StrBufRemove_token(hdr->HR.browser_host, 0, ',');
666 StrBufTrim(hdr->HR.browser_host);
669 void Header_HandleIfModSince(StrBuf *Line, ParsedHttpHdrs *hdr)
671 hdr->HR.if_modified_since = httpdate_to_timestamp(Line);
674 void Header_HandleAcceptEncoding(StrBuf *Line, ParsedHttpHdrs *hdr)
679 if (strstr(&ChrPtr(Line)[16], "gzip")) {
683 const char *ReqStrs[eNONE] = {
696 ServerStartModule_CONTEXT
700 HttpReqTypes = NewHash(1, NULL);
701 HttpHeaderHandler = NewHash(1, NULL);
703 v = malloc(sizeof(long));
705 Put(HttpReqTypes, HKEY("GET"), v, NULL);
707 v = malloc(sizeof(long));
709 Put(HttpReqTypes, HKEY("POST"), v, NULL);
711 v = malloc(sizeof(long));
713 Put(HttpReqTypes, HKEY("OPTIONS"), v, NULL);
715 v = malloc(sizeof(long));
717 Put(HttpReqTypes, HKEY("PROPFIND"), v, NULL);
719 v = malloc(sizeof(long));
721 Put(HttpReqTypes, HKEY("PUT"), v, NULL);
723 v = malloc(sizeof(long));
725 Put(HttpReqTypes, HKEY("DELETE"), v, NULL);
727 v = malloc(sizeof(long));
729 Put(HttpReqTypes, HKEY("HEAD"), v, NULL);
731 v = malloc(sizeof(long));
733 Put(HttpReqTypes, HKEY("MOVE"), v, NULL);
735 v = malloc(sizeof(long));
737 Put(HttpReqTypes, HKEY("COPY"), v, NULL);
741 ServerShutdownModule_CONTEXT
744 DeleteHash(&HttpReqTypes);
745 DeleteHash(&HttpHeaderHandler);
748 void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F)
751 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
752 memset(pHdr, 0, sizeof(OneHttpHeader));
754 Put(HttpHeaderHandler, Name, Len, pHdr, DestroyHttpHeaderHandler);
762 RegisterHeaderHandler(HKEY("CONTENT-LENGTH"), Header_HandleContentLength);
763 RegisterHeaderHandler(HKEY("CONTENT-TYPE"), Header_HandleContentType);
764 RegisterHeaderHandler(HKEY("USER-AGENT"), Header_HandleUserAgent);
765 RegisterHeaderHandler(HKEY("X-FORWARDED-HOST"), Header_HandleXFFHost); /* Apache way... */
766 RegisterHeaderHandler(HKEY("X-REAL-IP"), Header_HandleXFFHost); /* NGinX way... */
767 RegisterHeaderHandler(HKEY("HOST"), Header_HandleHost);
768 RegisterHeaderHandler(HKEY("X-FORWARDED-FOR"), Header_HandleXFF);
769 RegisterHeaderHandler(HKEY("ACCEPT-ENCODING"), Header_HandleAcceptEncoding);
770 RegisterHeaderHandler(HKEY("IF-MODIFIED-SINCE"), Header_HandleIfModSince);
772 RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, NULL, CTX_NONE);
773 RegisterNamespace("NONCE", 0, 0, tmplput_nonce, NULL, 0);
775 WebcitAddUrlHandler(HKEY("404"), "", 0, do_404, ANONYMOUS|COOKIEUNNEEDED);
777 * Look for commonly-found probes of malware such as worms, viruses, trojans, and Microsoft Office.
778 * Short-circuit these requests so we don't have to send them through the full processing loop.
780 WebcitAddUrlHandler(HKEY("scripts"), "", 0, do_404, ANONYMOUS|BOGUS); /* /root.exe - Worms and trojans and viruses, oh my! */
781 WebcitAddUrlHandler(HKEY("c"), "", 0, do_404, ANONYMOUS|BOGUS); /* /winnt */
782 WebcitAddUrlHandler(HKEY("MSADC"), "", 0, do_404, ANONYMOUS|BOGUS);
783 WebcitAddUrlHandler(HKEY("_vti"), "", 0, do_404, ANONYMOUS|BOGUS); /* Broken Microsoft DAV implementation */
784 WebcitAddUrlHandler(HKEY("MSOffice"), "", 0, do_404, ANONYMOUS|BOGUS); /* Stoopid MSOffice thinks everyone is IIS */
785 WebcitAddUrlHandler(HKEY("nonexistenshit"), "", 0, do_404, ANONYMOUS|BOGUS); /* Exploit found in the wild January 2009 */
790 HttpNewModule_CONTEXT
791 (ParsedHttpHdrs *httpreq)
793 httpreq->PlainArgs = NewStrBufPlain(NULL, SIZ);
794 httpreq->this_page = NewStrBufPlain(NULL, SIZ);
798 HttpDetachModule_CONTEXT
799 (ParsedHttpHdrs *httpreq)
801 FlushStrBuf(httpreq->PlainArgs);
802 FlushStrBuf(httpreq->this_page);
803 FlushStrBuf(httpreq->PlainArgs);
804 DeleteHash(&httpreq->HTTPHeaders);
805 memset(&httpreq->HR, 0, sizeof(HdrRefs));
809 HttpDestroyModule_CONTEXT
810 (ParsedHttpHdrs *httpreq)
812 FreeStrBuf(&httpreq->this_page);
813 FreeStrBuf(&httpreq->PlainArgs);
814 FreeStrBuf(&httpreq->this_page);
815 FreeStrBuf(&httpreq->PlainArgs);
816 DeleteHash(&httpreq->HTTPHeaders);