How to pass the "Content-Length" value in the header using the Curl command

How to convey the length of the content, for example. --header Content-Length:1000 in the curl command. I used it as a team, but it did not work

 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" 

This command submits a file to web services developed in Jersey

+14
source share
3 answers

Try this: curl -X POST http://localhost:9090/pro/v1/files -d "Content-Length: 0"

The curl -d flag allows you to add data to the request body. According to his docs:

-d, - -d ata (HTTP) Sends the specified data in the POST request to the HTTP server in the same way as the browser does when the user completes the HTML form and clicks the submit button. This will force curl to transfer data to the server using application-type / x-www-form-urlencoded.

+6
source

Use -d "" causes CURL to send Content-Length: 0

+13
source

Adding such headers should do the trick:

 -H 'content-length: 1000' \ 
+3
source

Source: https://habr.com/ru/post/1235080/


All Articles