编程语言
首页 > 编程语言> > python-将文件发布到Jenkins失败

python-将文件发布到Jenkins失败

作者:互联网

我正在尝试通过multipart / form-data将文件从Python发布到Jenkins.请求正文如下所示:

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

PHhtbD4NCjwveG1sPg0K

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

这导致jenkins在其端提出异常,但最相关的部分如下:

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)

我的POST请求出了什么问题?

编辑:
请求标头如下:

内容类型:

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

MIME-版本:

1.0

解决方法:

我相信Content-Disposition:文件;应替换为Content-Disposition:附件;. FileUploadBase的源代码未提及“文件”,而RFC 2183并未将“文件”列出为内容处置的值.

标签:python,jenkins,multipartform-data,http-post
来源: https://codeday.me/bug/20191013/1909633.html