문제

I would like to have the same size of the automatic Content-Length header.

I will explain with examples :

When I do this : echo "testing" | wc -c // The result is : 8

or

When I do this : stat -c '%s' "test.txt" (on a file who contain the word : "testing") // The result is 8

BUT

When I do this : curl -v -d "testing" http://www.google.fr // The result is Content-Length: 7

OR

When I do this : curl -v -d "@test.txt" http://www.google.fr // The result is Content-Length: 7

Why ?

How can I have the same size ?

Thank you for your help.

Ben

도움이 되었습니까?

해결책

echo adds a newline character, so 7 + newline = 8

The curl -d option sends only the quoted characters.

To suppress the newline use `-n', this will give 7:

echo -n "testing" | wc -c

or use printf instead:

printf "testing" | wc -c
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top