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.
It's a question about
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.