cURL / Mailing Lists / curl-library / Single Mail

curl-library

malformed multipart/form-data with zero-byte section?

From: Mohun Biswas <m_biswas_at_mailinator.com>
Date: Sun, 24 Oct 2004 13:29:54 -0400

My app uses libcurl on the client side to upload file data to a server
running Apache Tomcat and using Apache FileUpload. The client code is
quite basic; the relevant form-data section is below:

        res = curl_formadd(&formpost, &lastptr,
                CURLFORM_CONTENTTYPE, "application/binary",
                CURLFORM_COPYNAME, path,
                CURLFORM_FILE, path, CURLFORM_END);

This has worked fine for quite a while but I just ran into a special
case. When the file to be uploaded has zero length the FileUpload parser
hangs on the server side. A little network tracing reveals that
zero-length files uploaded via the code above have no closing boundary
delimiter. The request looks like this:

> POST /upload HTTP/1.1
User-Agent: XYZ/0.5 (SunOS_sparc_5.9)
Host: piglet:8080
Pragma: no-cache
Accept: */*
Cookie: JSESSIONID=D67FD8924005AB5803034924242A62BE
Content-Length: 689
Content-Type: multipart/form-data;
boundary=----------------------------089aa8c52de2

and it ends with no "----------------------------089aa8c52de2--" line.

So - is this a malformed part and thus a libcurl problem or is it
normal/standard-conformant behavior and a problem with the FileUpload
class? I've browsed through RFCs 2616, 2388, and 2046 but haven't seen
anything referring to special handling of zero-length parts or any
situation where the closing delimiter can be skipped. I should be able
to put together a test case if need be but would like some guidance on
what should be happening before investing the time.

This is libcurl 7.12.2.

Thanks,
M. Biswas
Received on 2004-10-24