]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
Hunt for mime_parser bugs...
[citadel.git] / webcit / webcit.c
index ab87150220ec4f9f2faee3b55ad2bef06e2ed210..a234824210c9cba351648a4b078ecaf3d03dcf89 100644 (file)
 StrBuf *csslocal = NULL;
 HashList *HandlerHash = NULL;
 
+void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt)
+{
+        wcsession *WCC = WC;
+       int n;
+       
+       n = GetCount(WCC->Hdr->HTTPHeaders);
+       Put(WCC->Hdr->HTTPHeaders, IKEY(n), Data, DeleteIt);
+}
 
 void DeleteWebcitHandler(void *vHandler)
 {
@@ -46,11 +54,6 @@ void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP)
                StrBufAppendTemplate(Target, TP, WCC->Hdr->HR.Handler->DisplayName, 0);
 }
 
-void tmplput_HOST_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP) 
-{
-       wcsession *WCC = WC;
-       StrBufAppendTemplate(Target, TP, WCC->Hdr->HR.http_host, 0);
-}
 
 /*
  * web-printing funcion. uses our vsnprintf wrapper
@@ -479,23 +482,22 @@ void seconds_since_last_gexp(void)
 int ReadPostData(void)
 {
        int rc;
-       int body_start = 0;
+       int urlencoded_post = 0;
        wcsession *WCC = WC;
        StrBuf *content = NULL;
        
+       urlencoded_post = (strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0) ;
+
        content = NewStrBufPlain(NULL, WCC->Hdr->HR.ContentLength + 256);
 
-       StrBufPrintf(content, 
+       if (!urlencoded_post)
+       {
+               StrBufPrintf(content, 
                     "Content-type: %s\n"
-                    "Content-length: %ld\n\n",
-                    ChrPtr(WCC->Hdr->HR.ContentType), 
+                            "Content-length: %ld\n\n",
+                            ChrPtr(WCC->Hdr->HR.ContentType), 
                             WCC->Hdr->HR.ContentLength);
-/*
-  hprintf("Content-type: %s\n"
-  "Content-length: %d\n\n",
-  ContentType, ContentLength);
-*/
-       body_start = StrLength(content);
+       }
 
        /** Read the entire input data at once. */
        rc = client_read_to(WCC->Hdr, content, 
@@ -505,8 +507,7 @@ int ReadPostData(void)
                return rc;
                
        
-       if (!strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33)) {
-               StrBufCutLeft(content, body_start);
+       if (urlencoded_post) {
                ParseURLParams(content);
        } else if (!strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "multipart", 9)) {
                char *Buf;
@@ -864,7 +865,6 @@ InitModule_WEBCIT
        RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, NULL, CTX_NONE);
        RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, NULL, CTX_NONE);
        RegisterNamespace("URL:DISPLAYNAME", 0, 1, tmplput_HANDLER_DISPLAYNAME, NULL, CTX_NONE);
-       RegisterNamespace("URL:HOSTNAME", 0, 1, tmplput_HOST_DISPLAYNAME, NULL, CTX_NONE);
 
        
        snprintf(dir, SIZ, "%s/webcit.css", static_local_dir);