【发布时间】:2026-01-08 22:15:01
【问题描述】:
我正在构建一个 Web 服务器作为练习。当我收到一个原始请求时,它会被解析成一个简单的语法树,并通过评估这棵树来构建一个响应。我的问题是:When sending an HTTP Response, does the Content-Type field get set by taking the file extension of the requested resource and looking it up in a dictionary of MIME-types? 一个很好的例子是对 favicon.ico 的响应是如何构建的剖析。对此的任何见解将是最有帮助的。谢谢。
【问题讨论】:
-
这听起来像是一道大学作业题...
-
我只是假设答案是我所想的......您获取所请求资源的文件扩展名,并在您的 MIME 映射中查找它。