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>开发者_StackOverflow社区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
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.
精彩评论