0

Some times in small shell scripts, I use an http request on a raw text file with no header, only a uuid string for identification. For example, in the apache document root, I might have a file uuid.html that contains only the uuid string 2c465f47-a734-43a0-98ab-13a2b574ccaa, no header, nothing else. When I do an hhtp request on this file, say via content=$(wget somedomain/uuid.html -o /dev/null -q -O -), where somedomain resolve to my server, as expected $content is set to the uuid string. I do this to make sure that somedomain is really resolving to my server. There might be a better way to accomplish the same goal, but that is not my question. The question is whether this is the expected behavior in accordance to HTTP specification? I mean, perhaps, this behavior is not a part of the HTTP specification and, in some other server, $content will not be the uuid string, some extra header might be automatically added. I know, I could go and read the specification myself, but I feel it is such a simple question that one should not have to go back to the original, lengthy and verbose specification to figure out the answer.

  • Why would you expect that request and response not to have any headers? Wget is a fairly advanced tool and it handles all the headers for you. Unless you use the --save-headers command line flag, it wouldn't show them to you at all, even though it uses them. – Stephen Ostermiller Aug 15 '19 at 17:32
1

You may not be explicitly setting HTTP headers but wget certainly will be.

If you run the same command with the -d (debug) flag you'll see more verbose output including the request and response headers:

$ wget -d https://webmasters.stackexchange.com/robots.txt
[...]
---request begin---
GET /robots.txt HTTP/1.1
User-Agent: Wget/1.20.1 (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: webmasters.stackexchange.com
Connection: Keep-Alive
[...]
  • If you add that wget also manages the response header, which is what the question was about, then I will accept it. BTW, I realized soon after having asked my question that it showed that I did not know the HTTP protocol. Of course, there is always an header in the HTTP response. It's wget that strips the header. I knew these things, but they were just not lively in my mind. I feel ashamed. – Dominic108 Aug 15 '19 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.