How to get the content-type of a file

前端 未结 2 422
北恋
北恋 2021-01-28 00:43

I am implementing a HTTP/1.0 server that processes GET or HEAD request.

I\'ve finished Date, Last-Modified, and

2条回答
  •  没有蜡笔的小新
    2021-01-28 01:18

    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.

提交回复
热议问题