It's a question about wget. I have a simple file uuid.html in the document root that contains a single line 54da5638-099d-4cf3-9319-c436fcb81334. I get the line in a shell script with content=$(wget localhost/uuid.html -O -). My server, Apache, automatically assigns the content-type text/html to the outputdocument in the response that is returned to wget. Is it reliable to consider that, in this particular case where the file only contains an uuid string, the content-type in the response header does not affect what is returned by wget and assigned to $content? I know that Apache would set the content-type to text/plain in the response header if I used the extension .txt for the file. That's not the question. Also, Is it necessary to specify content-type in http response header? is a similar question, but the context is different: they consider that the request is made by a browser. Also, of course, I checked that it works on my server. The question is whether this is reliable, irrespective of the environment.

  • I would have deleted the question had I enough reputation, because the correct thing to do is to make sure that the file has the correct content-type. If you don't know the content-type, then to answer the question, one has to consider the behavior of wget on an UUID string, for every content-type. It's not interesting.
    – Dominic108
    Aug 17, 2019 at 19:06

1 Answer 1


The content-type is used by browsers to figure out how to display the content. Browsers have to choose the rendering method based on the content type. Rendering plain text is very different than rendering HTML.

wget performs the same action for all files: it saves them to disk. In my experience it doesn't pay attention to the Content-Type header, it just saves the file. Most file systems don't have any mechanism to store meta data about the file other than its filename and permissions. So the content type doesn't even get stored.

The one exception might be Mac OS. Macs file systems have the ability to store far more meta data about files than that of other file systems reference. I've never used wget on Mac, but it is possible that the content type gets stored as file metadata there. That would then effect which program is chosen to open the file using the default action.

Of course, other file systems are usually going to guess based on the file extension which is .html. Since that is incorrect as well, the systems may behave the same as to which types of applications get chosen to open the saved file.

If you are consuming the uuid with a specific script or application, it probably doesn't matter to you what the OS would choose as the default editor and viewer for the file. I can't imagine that your use case is going to cause any unforeseen problems on Windows, Mac, or Linux.

  • Well, the -r option is not used in my case, but if it was used and the string turned out to contain an html link, the content-type text/html would make a difference. So, in principle, it's possible that a weird content-type would make wget behave differently, even without the -roption and an html link.
    – Dominic108
    Aug 18, 2019 at 0:48
  • I mean, maybe such a weird content-type does not exist, but this depends on wget. I am just saying that what happens with the -r option and the content-type text/html makes me worry that such weird content-type does exist.
    – Dominic108
    Aug 18, 2019 at 0:53
  • That is true, wget can scan html for links. Of course it won't find any in your simple uuid document. Aug 18, 2019 at 8:50
  • Yes, I will accept your answer. Otherwise, the question made no sense: why asking, if you doubt the expertise thereafter. In a context where you cannot fix the content-type, your answer is the best one can have.
    – Dominic108
    Aug 18, 2019 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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