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; /**< our sessions ????*/
20 pthread_key_t MyConKey; /**< TSD key for MySession() */
21 HashList *HttpReqTypes = NULL;
22 HashList *HttpHeaderHandler = NULL;
23 extern HashList *HandlerHash;
25 void DestroyHttpHeaderHandler(void *V)
28 pHdr = (OneHttpHeader*) V;
29 FreeStrBuf(&pHdr->Val);
33 void shutdown_sessions(void)
37 for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
42 void do_housekeeping(void)
45 wcsession *sessions_to_kill = NULL;
47 static int num_threads = MIN_WORKER_THREADS;
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)) >
60 (time_t) WEBCIT_TIMEOUT) {
64 /** Remove sessions flagged for kill */
67 /** remove session from linked list */
68 if (sptr == SessionList) {
69 SessionList = SessionList->next;
71 else for (ss=SessionList;ss!=NULL;ss=ss->next) {
72 if (ss->next == sptr) {
73 ss->next = ss->next->next;
77 sptr->next = sessions_to_kill;
78 sessions_to_kill = sptr;
81 pthread_mutex_unlock(&SessionListMutex);
84 * Now free up and destroy the culled sessions.
86 while (sessions_to_kill != NULL) {
87 lprintf(3, "Destroying session %d\n", sessions_to_kill->wc_session);
88 pthread_mutex_lock(&sessions_to_kill->SessionMutex);
89 pthread_mutex_unlock(&sessions_to_kill->SessionMutex);
90 sptr = sessions_to_kill->next;
92 session_destroy_modules(&sessions_to_kill);
93 sessions_to_kill = sptr;
98 * If there are more sessions than threads, then we should spawn
99 * more threads ... up to a predefined maximum.
101 while ( (num_sessions > num_threads)
102 && (num_threads <= MAX_WORKER_THREADS) ) {
103 spawn_another_worker_thread();
105 lprintf(3, "There are %d sessions and %d threads active.\n",
106 num_sessions, num_threads);
112 * Wake up occasionally and clean house
114 void housekeeping_loop(void)
117 sleeeeeeeeeep(HOUSEKEEPING);
124 * Create a Session id
125 * Generate a unique WebCit session ID (which is not the same thing as the
126 * Citadel session ID).
128 int GenerateSessionID(void)
130 static int seq = (-1);
133 seq = (int) time(NULL);
139 wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
141 wcsession *sptr, *TheSession = NULL;
143 pthread_mutex_lock(ListMutex);
145 ((sptr != NULL) && (TheSession == NULL));
148 /** If HTTP-AUTH, look for a session with matching credentials */
149 switch (Hdr->HR.got_auth)
152 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))) )
160 /** If cookie-session, look for a session with matching session ID */
161 if ( (Hdr->HR.desired_session != 0) &&
162 (sptr->wc_session == Hdr->HR.desired_session))
169 pthread_mutex_unlock(ListMutex);
173 wcsession *CreateSession(int Lockable, wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
175 wcsession *TheSession;
176 lprintf(3, "Creating a new session\n");
177 TheSession = (wcsession *)
178 malloc(sizeof(wcsession));
179 memset(TheSession, 0, sizeof(wcsession));
180 TheSession->Hdr = Hdr;
181 TheSession->SessionKey = Hdr->HR.SessionKey;
182 TheSession->serv_sock = (-1);
183 TheSession->chat_sock = (-1);
184 TheSession->is_mobile = -1;
186 pthread_setspecific(MyConKey, (void *)TheSession);
188 /* If we're recreating a session that expired, it's best to give it the same
189 * session number that it had before. The client browser ought to pick up
190 * the new session number and start using it, but in some rare situations it
191 * doesn't, and that's a Bad Thing because it causes lots of spurious sessions
194 if (Hdr->HR.desired_session == 0) {
195 TheSession->wc_session = GenerateSessionID();
198 TheSession->wc_session = Hdr->HR.desired_session;
201 session_new_modules(TheSession);
204 pthread_mutex_init(&TheSession->SessionMutex, NULL);
206 if (ListMutex != NULL)
207 pthread_mutex_lock(ListMutex);
209 if (wclist != NULL) {
210 TheSession->nonce = rand();
211 TheSession->next = *wclist;
212 *wclist = TheSession;
214 if (ListMutex != NULL)
215 pthread_mutex_unlock(ListMutex);
222 * \brief Detects a 'mobile' user agent
224 int is_mobile_ua(char *user_agent) {
225 if (strstr(user_agent,"iPhone OS") != NULL) {
227 } else if (strstr(user_agent,"Windows CE") != NULL) {
229 } else if (strstr(user_agent,"SymbianOS") != NULL) {
231 } else if (strstr(user_agent, "Opera Mobi") != NULL) {
233 } else if (strstr(user_agent, "Firefox/2.0.0 Opera 9.51 Beta") != NULL) {
234 /* For some reason a new install of Opera 9.51beta decided to spoof. */
240 /* If it's a "force 404" situation then display the error and bail. */
243 hprintf("HTTP/1.1 404 Not found\r\n");
244 hprintf("Content-Type: text/plain\r\n");
245 wprintf("Not found\r\n");
249 int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
252 void *vLine, *vHandler;
253 const char *Pos = NULL;
256 Hdr->HR.ReqLine = Line;
257 /* The requesttype... GET, POST... */
258 StrBufExtract_token(Buf, Hdr->HR.ReqLine, 0, ' ');
259 if (GetHash(HttpReqTypes, SKEY(Buf), &vLine) &&
262 Hdr->HR.eReqType = *(long*)vLine;
265 Hdr->HR.eReqType = eGET;
268 StrBufCutLeft(Hdr->HR.ReqLine, StrLength(Buf) + 1);
270 /* the HTTP Version... */
271 StrBufExtract_token(Buf, Hdr->HR.ReqLine, 1, ' ');
272 StrBufCutRight(Hdr->HR.ReqLine, StrLength(Buf) + 1);
274 if (StrLength(Buf) == 0) {
275 Hdr->HR.eReqType = eGET;
279 StrBufAppendBuf(Hdr->this_page, Hdr->HR.ReqLine, 0);
280 /* chop Filename / query arguments */
281 Args = strchr(ChrPtr(Hdr->HR.ReqLine), '?');
282 if (Args == NULL) /* whe're not that picky about params... TODO: this will spoil '&' in filenames.*/
283 Args = strchr(ChrPtr(Hdr->HR.ReqLine), '&');
285 Args ++; /* skip the ? */
286 StrBufPlain(Hdr->PlainArgs,
288 StrLength(Hdr->HR.ReqLine) -
289 (Args - ChrPtr(Hdr->HR.ReqLine)));
290 StrBufCutAt(Hdr->HR.ReqLine, 0, Args - 1);
291 } /* don't parse them yet, maybe we don't even care... */
293 /* now lookup what we are going to do with this... */
294 /* skip first slash */
295 StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
297 StrBufExtract_NextToken(Buf, Hdr->HR.ReqLine, &Pos, '/');
299 GetHash(HandlerHash, SKEY(Buf), &vHandler),
300 Hdr->HR.Handler = (WebcitHandler*) vHandler;
301 if (Hdr->HR.Handler == NULL)
304 * If the request is prefixed by "/webcit" then chop that off. This
305 * allows a front end web server to forward all /webcit requests to us
306 * while still using the same web server port for other things.
308 if ((Hdr->HR.Handler->Flags & URLNAMESPACE) != 0)
312 /* remove the handlername from the URL */
314 StrBufCutLeft(Hdr->HR.ReqLine,
315 Pos - ChrPtr(Hdr->HR.ReqLine));
318 if (Hdr->HR.Handler != NULL) {
319 if ((Hdr->HR.Handler->Flags & BOGUS) != 0)
321 Hdr->HR.DontNeedAuth = (
322 ((Hdr->HR.Handler->Flags & ISSTATIC) != 0) ||
323 ((Hdr->HR.Handler->Flags & ANONYMOUS) != 0)
327 Hdr->HR.DontNeedAuth = 1; /* Flat request? show him the login screen... */
333 int AnalyseHeaders(ParsedHttpHdrs *Hdr)
339 HashPos *at = GetNewHashPos(Hdr->HTTPHeaders, 0);
341 while (GetNextHashPos(Hdr->HTTPHeaders, at, &HKLen, &HashKey, &vHdr) &&
343 pHdr = (OneHttpHeader *)vHdr;
344 if (pHdr->HaveEvaluator)
345 pHdr->H(pHdr->Val, Hdr);
352 /*const char *nix(void *vptr) {return ChrPtr( (StrBuf*)vptr);}*/
355 * Read in the request
357 int ReadHTTPRequest (ParsedHttpHdrs *Hdr)
359 const char *pch, *pchs, *pche;
361 StrBuf *Line, *LastLine, *HeaderName;
366 HeaderName = NewStrBuf();
370 Line = NewStrBufPlain(NULL, SIZ / 4);
372 if (ClientGetLine(Hdr, Line) < 0) return 1;
374 if (StrLength(Line) == 0) {
379 Hdr->HTTPHeaders = NewHash(1, NULL);
380 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
381 memset(pHdr, 0, sizeof(OneHttpHeader));
383 Put(Hdr->HTTPHeaders, HKEY("GET /"), pHdr, DestroyHttpHeaderHandler);
384 lprintf(9, "%s\n", ChrPtr(Line));
385 isbogus = ReadHttpSubject(Hdr, Line, HeaderName);
390 /* Do we need to Unfold? */
391 if ((LastLine != NULL) &&
392 (isspace(*ChrPtr(Line)))) {
393 pch = pchs = ChrPtr(Line);
394 pche = pchs + StrLength(Line);
395 while (isspace(*pch) && (pch < pche))
397 StrBufCutLeft(Line, pch - pchs);
398 StrBufAppendBuf(LastLine, Line, 0);
404 StrBufSanitizeAscii(Line, '§');
405 StrBufExtract_token(HeaderName, Line, 0, ':');
408 pch = pchs + StrLength(HeaderName) + 1;
409 pche = pchs + StrLength(Line);
410 while (isspace(*pch) && (pch < pche))
412 StrBufCutLeft(Line, pch - pchs);
414 StrBufUpCase(HeaderName);
416 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
417 memset(pHdr, 0, sizeof(OneHttpHeader));
420 if (GetHash(HttpHeaderHandler, SKEY(HeaderName), &vF) &&
423 OneHttpHeader *FHdr = (OneHttpHeader*) vF;
425 pHdr->HaveEvaluator = 1;
427 Put(Hdr->HTTPHeaders, SKEY(HeaderName), pHdr, DestroyHttpHeaderHandler);
429 } while (Line != NULL);
431 FreeStrBuf(&HeaderName);
436 void OverrideRequest(ParsedHttpHdrs *Hdr, const char *Line, long len)
438 StrBuf *Buf = NewStrBuf();
440 FlushStrBuf(Hdr->HR.ReqLine);
441 StrBufPlain(Hdr->HR.ReqLine, Line, len);
442 ReadHttpSubject(Hdr, Hdr->HR.ReqLine, Buf);
450 * This loop gets called once for every HTTP connection made to WebCit. At
451 * this entry point we have an HTTP socket with a browser allegedly on the
452 * other end, but we have not yet bound to a WebCit session.
454 * The job of this function is to locate the correct session and bind to it,
455 * or create a session if necessary and bind to it, then run the WebCit
456 * transaction loop. Afterwards, we unbind from the session. When this
457 * function returns, the worker thread is then free to handle another
460 void context_loop(ParsedHttpHdrs *Hdr)
463 wcsession *TheSession;
464 struct timeval tx_start;
465 struct timeval tx_finish;
467 gettimeofday(&tx_start, NULL); /* start a stopwatch for performance timing */
470 * Find out what it is that the web browser is asking for
472 isbogus = ReadHTTPRequest(Hdr);
475 isbogus = AnalyseHeaders(Hdr);
478 ((Hdr->HR.Handler != NULL) &&
479 ((Hdr->HR.Handler->Flags & BOGUS) != 0)))
483 Bogus = CreateSession(0, NULL, Hdr, NULL);
487 lprintf(9, "HTTP: 404 [%ld.%06ld] %s %s \n",
488 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
489 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
490 ReqStrs[Hdr->HR.eReqType],
491 ChrPtr(Hdr->this_page)
493 session_detach_modules(Bogus);
494 session_destroy_modules(&Bogus);
498 if ((Hdr->HR.Handler != NULL) &&
499 ((Hdr->HR.Handler->Flags & ISSTATIC) != 0))
502 Static = CreateSession(0, NULL, Hdr, NULL);
504 Hdr->HR.Handler->F();
506 /* How long did this transaction take? */
507 gettimeofday(&tx_finish, NULL);
510 if ((Hdr->HR.Handler != NULL) ||
511 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
513 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
514 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
515 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
516 ReqStrs[Hdr->HR.eReqType],
517 ChrPtr(Hdr->this_page)
519 session_detach_modules(Static);
520 session_destroy_modules(&Static);
524 if (Hdr->HR.got_auth == AUTH_BASIC)
528 /* dbg_PrintHash(HTTPHeaders, nix, NULL); */
531 * See if there's an existing session open with the desired ID or user/pass
535 if (TheSession == NULL) {
536 TheSession = FindSession(&SessionList, Hdr, &SessionListMutex);
540 * Create a new session if we have to
542 if (TheSession == NULL) {
543 TheSession = CreateSession(1, &SessionList, Hdr, &SessionListMutex);
545 if ((StrLength(Hdr->c_username) == 0) &&
546 (!Hdr->HR.DontNeedAuth)) {
547 OverrideRequest(Hdr, HKEY("GET /static/nocookies.html?force_close_session=yes HTTP/1.0"));
548 Hdr->HR.prohibit_caching = 1;
551 if (StrLength(Hdr->c_language) > 0) {
552 lprintf(9, "Session cookie requests language '%s'\n", ChrPtr(Hdr->c_language));
553 set_selected_language(ChrPtr(Hdr->c_language));
554 go_selected_language();
559 * A future improvement might be to check the session integrity
560 * at this point before continuing.
564 * Bind to the session and perform the transaction
566 pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
567 pthread_setspecific(MyConKey, (void *)TheSession);
569 TheSession->lastreq = time(NULL); /* log */
570 TheSession->Hdr = Hdr;
572 session_attach_modules(TheSession);
573 session_loop(); /* do transaction */
576 /* How long did this transaction take? */
577 gettimeofday(&tx_finish, NULL);
581 if ((Hdr->HR.Handler != NULL) &&
582 ((Hdr->HR.Handler->Flags & LOGCHATTY) == 0))
584 lprintf(9, "HTTP: 200 [%ld.%06ld] %s %s \n",
585 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
586 ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
587 ReqStrs[Hdr->HR.eReqType],
588 ChrPtr(Hdr->this_page)
591 session_detach_modules(TheSession);
593 TheSession->Hdr = NULL;
594 pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */
597 void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
600 StrBufAppendPrintf(Target, "%ld",
601 (WCC != NULL)? WCC->nonce:0);
604 void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
606 StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
609 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
611 StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
614 void Header_HandleContentLength(StrBuf *Line, ParsedHttpHdrs *hdr)
616 hdr->HR.ContentLength = StrToi(Line);
619 void Header_HandleContentType(StrBuf *Line, ParsedHttpHdrs *hdr)
621 hdr->HR.ContentType = Line;
624 void Header_HandleUserAgent(StrBuf *Line, ParsedHttpHdrs *hdr)
626 hdr->HR.user_agent = Line;
628 /* TODO: do this later on session creating
629 if ((WCC->is_mobile < 0) && is_mobile_ua(&buf[12])) {
640 void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
642 if ((follow_xff) && (hdr->HR.http_host != NULL))
645 hdr->HR.http_host = Line;
648 void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
651 hdr->HR.http_host = Line;
655 void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
657 hdr->HR.browser_host = Line;
659 while (StrBufNum_tokens(hdr->HR.browser_host, ',') > 1) {
660 StrBufRemove_token(hdr->HR.browser_host, 0, ',');
662 StrBufTrim(hdr->HR.browser_host);
665 void Header_HandleIfModSince(StrBuf *Line, ParsedHttpHdrs *hdr)
667 hdr->HR.if_modified_since = httpdate_to_timestamp(Line);
670 void Header_HandleAcceptEncoding(StrBuf *Line, ParsedHttpHdrs *hdr)
675 if (strstr(&ChrPtr(Line)[16], "gzip")) {
679 const char *ReqStrs[eNONE] = {
692 ServerStartModule_CONTEXT
696 HttpReqTypes = NewHash(1, NULL);
697 HttpHeaderHandler = NewHash(1, NULL);
699 v = malloc(sizeof(long));
701 Put(HttpReqTypes, HKEY("GET"), v, NULL);
703 v = malloc(sizeof(long));
705 Put(HttpReqTypes, HKEY("POST"), v, NULL);
707 v = malloc(sizeof(long));
709 Put(HttpReqTypes, HKEY("OPTIONS"), v, NULL);
711 v = malloc(sizeof(long));
713 Put(HttpReqTypes, HKEY("PROPFIND"), v, NULL);
715 v = malloc(sizeof(long));
717 Put(HttpReqTypes, HKEY("PUT"), v, NULL);
719 v = malloc(sizeof(long));
721 Put(HttpReqTypes, HKEY("DELETE"), v, NULL);
723 v = malloc(sizeof(long));
725 Put(HttpReqTypes, HKEY("HEAD"), v, NULL);
727 v = malloc(sizeof(long));
729 Put(HttpReqTypes, HKEY("MOVE"), v, NULL);
731 v = malloc(sizeof(long));
733 Put(HttpReqTypes, HKEY("COPY"), v, NULL);
737 ServerShutdownModule_CONTEXT
740 DeleteHash(&HttpReqTypes);
741 DeleteHash(&HttpHeaderHandler);
744 void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F)
747 pHdr = (OneHttpHeader*) malloc(sizeof(OneHttpHeader));
748 memset(pHdr, 0, sizeof(OneHttpHeader));
750 Put(HttpHeaderHandler, Name, Len, pHdr, DestroyHttpHeaderHandler);
758 RegisterHeaderHandler(HKEY("CONTENT-LENGTH"), Header_HandleContentLength);
759 RegisterHeaderHandler(HKEY("CONTENT-TYPE"), Header_HandleContentType);
760 RegisterHeaderHandler(HKEY("USER-AGENT"), Header_HandleUserAgent);
761 RegisterHeaderHandler(HKEY("X-FORWARDED-HOST"), Header_HandleXFFHost);
762 RegisterHeaderHandler(HKEY("HOST"), Header_HandleHost);
763 RegisterHeaderHandler(HKEY("X-FORWARDED-FOR"), Header_HandleXFF);
764 RegisterHeaderHandler(HKEY("ACCEPT-ENCODING"), Header_HandleAcceptEncoding);
765 RegisterHeaderHandler(HKEY("IF-MODIFIED-SINCE"), Header_HandleIfModSince);
767 RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, CTX_NONE);
768 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, CTX_NONE);
769 RegisterNamespace("NONCE", 0, 0, tmplput_nonce, 0);
771 WebcitAddUrlHandler(HKEY("404"), do_404, ANONYMOUS|COOKIEUNNEEDED);
773 * Look for commonly-found probes of malware such as worms, viruses, trojans, and Microsoft Office.
774 * Short-circuit these requests so we don't have to send them through the full processing loop.
776 WebcitAddUrlHandler(HKEY("scripts"), do_404, ANONYMOUS|BOGUS); /* /root.exe - Worms and trojans and viruses, oh my! */
777 WebcitAddUrlHandler(HKEY("c"), do_404, ANONYMOUS|BOGUS); /* /winnt */
778 WebcitAddUrlHandler(HKEY("MSADC"), do_404, ANONYMOUS|BOGUS);
779 WebcitAddUrlHandler(HKEY("_vti"), do_404, ANONYMOUS|BOGUS); /* Broken Microsoft DAV implementation */
780 WebcitAddUrlHandler(HKEY("MSOffice"), do_404, ANONYMOUS|BOGUS); /* Stoopid MSOffice thinks everyone is IIS */
781 WebcitAddUrlHandler(HKEY("nonexistenshit"), do_404, ANONYMOUS|BOGUS); /* Exploit found in the wild January 2009 */
786 HttpNewModule_CONTEXT
787 (ParsedHttpHdrs *httpreq)
789 httpreq->PlainArgs = NewStrBufPlain(NULL, SIZ);
790 httpreq->this_page = NewStrBufPlain(NULL, SIZ);
794 HttpDetachModule_CONTEXT
795 (ParsedHttpHdrs *httpreq)
797 FlushStrBuf(httpreq->PlainArgs);
798 FlushStrBuf(httpreq->this_page);
799 FlushStrBuf(httpreq->PlainArgs);
800 DeleteHash(&httpreq->HTTPHeaders);
801 memset(&httpreq->HR, 0, sizeof(HdrRefs));
805 HttpDestroyModule_CONTEXT
806 (ParsedHttpHdrs *httpreq)
808 FreeStrBuf(&httpreq->this_page);
809 FreeStrBuf(&httpreq->PlainArgs);
810 FreeStrBuf(&httpreq->this_page);
811 FreeStrBuf(&httpreq->PlainArgs);
812 DeleteHash(&httpreq->HTTPHeaders);