在通过HTTP下载文件时是否应使用content-transfer-encoding标头? [英] Should content-transfer-encoding headers be use when downloading files via HTTP?

查看:1186
本文介绍了在通过HTTP下载文件时是否应使用content-transfer-encoding标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了如何使用PHP强制下载文件其中描述了设置 Content-Transfer-Encoding 。当用于通过HTTP下载文件时,此标头在与此应用程序一起使用时是否适用(它似乎与电子邮件相关)?如果是这样,应该为MS Word和Excel文件,ZIP文件,PDF和文本设置什么?

I recently came across How to force file download with PHP which describes setting Content-Transfer-Encoding. Is this header applicable when used with this application when used to download a file via HTTP (it appears to be email related)? If so, what should it be set as for MS Word and Excel files, ZIP files, PDFs, and Text?

header("Content-Transfer-Encoding: Binary"); 


推荐答案

它被虔诚地包含在carg-cult copy-粘贴程序员,因为它是在PHP.net上的 readfile()联机帮助页的评论中提到

It has been religiously included by carg-cult copy-paste programmers since it was mentioned in a comment to the readfile() manpage on PHP.net.

确实与HTTP无关,您可以安全地将其删除。

It indeed has little to do with HTTP and you can safely remove it.

这篇关于在通过HTTP下载文件时是否应使用content-transfer-encoding标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆