How to get the content-type of a file

前端 未结 2 398
北恋
北恋 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:07

    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).

提交回复
热议问题