1

I'm trying to POST a file to Jenkins from Python, via multipart/form-data. The request body looks like this:

--===============1849003312==
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: file; name="file0"; filename="meta.xml"

PHhtbD4NCjwveG1sPg0K

--===============1849003312==--

This causes Jenkins to raise an exception on its end however, the most relevant bits of which follow:

Exception: <br>Stacktrace: <pre>org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly
   at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:381)
   at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
   at org.kohsuke.stapler.RequestImpl.parseMultipartFormData(RequestImpl.java:767)
   at org.kohsuke.stapler.RequestImpl.getSubmittedForm(RequestImpl.java:782)

What's wrong with my POST request?

EDIT: The request headers are as follows:

Content-Type:

multipart/form-data; boundary="===============1849003312=="    

MIME-Version:

1.0
aknuds1
  • 65,625
  • 67
  • 195
  • 317

1 Answers1

0

I believe the Content-Disposition: file; should be replaced with Content-Disposition: attachment;. The source code of FileUploadBase does not mention "file", and RFC 2183 does not list "file" as a value for content-disposition.

Anders Lindahl
  • 41,582
  • 9
  • 89
  • 93
  • I tried changing 'file' to 'attachment' for Content-Disposition, it made no difference actually (the same exception occurs). Looking at the FileUploadBase.java source also, it doesn't look like the content disposition matters regarding the exception being thrown. – aknuds1 Aug 17 '11 at 08:02