【发布时间】:2013-05-29 14:04:41
【问题描述】:
我写了一个 TIdHTTPServer 网络服务器。 Indy 版本是 10,Delphi 是 2007。
我使用以下代码发回 jpeg、gif、png 等文件:
AResponseInfo.ServeFile(AContext,rootpath+ARequestInfo.document);
AResponseInfo.ContentType := 'image/jpeg';
AResponseInfo.ContentType := GetMimeTypeFromFile('.'+ExtractFileDir(rootpath+ARequestInfo.document));
图像在所有浏览器中都能正常显示。但我看到(通过 Chrome 中的控制台)它们被返回为 MIME 类型:text/html。 我已经尝试了 image/jpeg 和 GetMIMTypeFromFile 方法,并且都产生了 text/html。
我还需要打另一个电话吗?我在其他线程中看到了对 AResponseInfo.WriteHeader 函数的调用。但添加后会引发异常,标头被写入两次。
【问题讨论】: