Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • If echo "$contentlength" works, there is no reason echo "$contentlength bytes" does not work as well. Commented Mar 14, 2019 at 9:32
  • 2
    Could be the value of the variable ends in a CR character (line delimiters in HTTP headers are CRLF), 12345\r bytes would show up as " bytes" in a terminal as CR moves the cursor to the beginning of the line. Commented Mar 14, 2019 at 9:34
  • @StéphaneChazelas You're right. CR does not have this behavior when redirected. One can redirect the output and examine the result. Commented Mar 14, 2019 at 9:36
  • echo " $contentlength bytes" it returns this: ``` bytes``` Commented Mar 14, 2019 at 9:38
  • The way it's written (not proper header parsing, no sanitisation of the content length), this script has an arbitrary command injection vulnerability. Do not use a shell for this kind of thing. perl/python have HTTP or libcurl APIs. Commented Mar 14, 2019 at 9:38