Can I send a curl request without content-length?

1.1k Views Asked by At

I tried multile ways to send a post request using curl without curl but I am getting the header.

Method1:

curl --ignore-content-length --request PUT somehttps-domain/ignored-content-length.txt --upload-file ignored-content-length.txt -kv (I m getting actual content length at server side)

Method 2

curl --request PUT somehttps-domain/ignored-content-length.txt --upload-file ignored-content-length.txt --header 'Content-Lenght:' -kv (I m getting content length as zero at server side)

I dont want this header at server side. If I dont add also curl is adding by default.

Any suggestions??

1

There are 1 best solutions below

2
hanshenrik On

to force curl to not add a content-length to it's upload request (not sure why anyone would ever want to do that...), add

-H "Content-Length:"

to tell curl to ignore the content-length header it receives from the server (useful for bugged servers sending incorrect Content-Length headers), add

--ignore-content-length