Hunt for mime_parser bugs...
authorWilfried Goesgens <dothebart@citadel.org>
Fri, 10 Dec 2010 16:08:54 +0000 (17:08 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Fri, 10 Dec 2010 16:08:54 +0000 (17:08 +0100)
 - don't prepend the content-type/content-length - mime header if we don't intend to use it anyways.

webcit/webcit.c

index 64b42ee0ab63a292be29c8b6a8a787516296c17f..a234824210c9cba351648a4b078ecaf3d03dcf89 100644 (file)
@@ -482,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, 
@@ -508,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;