I am implementing a HTTP/1.0 server that processes GET
or HEAD
request.
I\'ve finished Date
, Last-Modified
, and
It depends how sophisticated you want to be.
If the files in question are all properly named and there are only several types to handle, having a switch based file suffix is sufficient. Going to the extreme case, making the right decision no matter what the file is would probably require either duplicating the functionality of Unix file
command or running it on file in question (and then translating the output to the proper Content-Type
).
You could either look at the file extension (which is what most web servers do -- see e.g. the /etc/mime.types
file; or you could use libmagic
to automatically determine the content type by looking at the first few bytes of the file.