]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* evade double calls to output_headers
[citadel.git] / webcit / messages.c
index 9b16e2a94b4d0a8a1f0a7ff6d32f4c38b45c1e72..6c8a97eb7ca390a5309a4c6ffd6ea4ee0f97bd48 100644 (file)
@@ -1515,7 +1515,6 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download)
                else {
                        content_type = NewStrBufDup(part->ContentType);
                }
-               output_headers(0, 0, 0, 0, 0, 0);
                StrBufAppendBuf(WC->WBuf, part->Data, 0);
                http_transmit_thing(ChrPtr(content_type), 0);
        } else {
@@ -1569,7 +1568,6 @@ void mimepart(int force_download)
                                CT = GuessMimeType(SKEY(WCC->WBuf));
                        }
                }
-               output_headers(0, 0, 0, 0, 0, 0);
                http_transmit_thing(CT, 0);
        } else {
                StrBufCutLeft(Buf, 4);
@@ -1588,26 +1586,23 @@ void mimepart(int force_download)
 /*
  * Read any MIME part of a message, from the server, into memory.
  */
-char *load_mimepart(long msgnum, char *partnum)
+StrBuf *load_mimepart(long msgnum, char *partnum)
 {
-       char buf[SIZ];
        off_t bytes;
-       char content_type[SIZ];
-       char *content;
+       StrBuf *Buf;
        
+       Buf = NewStrBuf();
        serv_printf("DLAT %ld|%s", msgnum, partnum);
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '6') {
-               bytes = extract_long(&buf[4], 0);
-               extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
-
-               content = malloc(bytes + 2);
-               serv_read(content, bytes);
+       StrBuf_ServGetlnBuffered(Buf);
+       if (GetServerStatus(Buf, NULL) == 6) {
+               StrBufCutLeft(Buf, 4);
+               bytes = StrBufExtract_long(Buf, 0, '|');
 
-               content[bytes] = 0;     /* null terminate for good measure */
-               return(content);
+               StrBuf_ServGetBLOBBuffered(Buf, bytes);
+               return(Buf);
        }
        else {
+               FreeStrBuf(&Buf);
                return(NULL);
        }
 }