问题 如何使用Curl命令在标头中传递“Content-Length”值


我怎样才能传递内容长度,例如。 --header Content-Length:1000 在curl命令中。 我在命令中使用它,但它没有用

curl -v -X POST -u "xxx@gmail.com:xxx123" \ 
     --header "Content-Length: 1000" \
     --header "Content-Type: multipart/mixed" \
     --header "X-REQUEST-ID:7fc7d038-4306-4fc5-89c3-7ac8a12a30d0" \
     -F "request={\"bumId\":\"d51f2978-5ce8-4c71-8503-b0ca438741dd\",\"fileType\":\"imageFile\"};type=application/json" \
     -F "file=@D:/file.pdf" \
     "http://localhost:9090/pro/v1/files"

此命令将文件发布到Jersey Java中开发的Web服务


7441
2017-11-03 05:44


起源



答案:


尝试这个: curl -X POST http://localhost:9090/pro/v1/files -d "Content-Length: 0"


5
2017-07-20 11:55



欢迎来到Stack Overflow!我建议在答案中添加一个解释,以便有类似问题的人能够更好地理解解决方案。或许解释一下 -d 国旗是?也许从Curl手册中添加一个片段? - Marvin


答案:


尝试这个: curl -X POST http://localhost:9090/pro/v1/files -d "Content-Length: 0"


5
2017-07-20 11:55



欢迎来到Stack Overflow!我建议在答案中添加一个解释,以便有类似问题的人能够更好地理解解决方案。或许解释一下 -d 国旗是?也许从Curl手册中添加一个片段? - Marvin


使用 -d "" 导致CURL发送 Content-Length: 0


7
2017-11-22 03:09





像这样添加标题应该可以解决问题:

-H 'content-length: 1000' \

3
2017-07-20 12:04