php - 服务器返回内容类型 application/x-httpd-php5 而不是 application/json
问题描述
我的 PHP 代码返回一个 JSON 字符串并设置为响应标头Content-Type: application/json
。
在 localhost 上它工作正常,它只返回我传递的 JSON 字符串。但是,在我的浏览器网络/标头上向远程服务器请求,内容类型是application/x-httpd-php5
. std-output
而内容,在 json 字符串之前,它会打印和该标题字符串中的文本:
X-Powered-By: PHP/7.2.8
Cache-Control: private, must-revalidate
Date: Wed, 08 Aug 2018 02:49:36 GMT
Content-Type: application/json
pragma: no-cache
expires: -1
X-Debug-Token: 187f4e
之后我得到了我发送的 json 字符串。
我的 PC 和主机的 PHP 版本是 PHP 7.2。我使用阿帕奇。托管也应该。但是,从浏览器响应标头中,我看到Server: nginx
.
从服务器到 Mime 类型,我得到了 application/json -> json。我上传了一个 .json 文件,我得到了Content-Type: application/json
. 我设置为我的 .htaccess 文件
AddDefaultCharset utf-8
AddType 'application/json; charset=UTF-8' .json
但仍然没有任何变化。
我不知道为什么在我的本地主机上我得到了Content-Type: application/json
,但在我得到的主机上application/x-httpd-php5
。
这是原始响应:
HTTP/2.0 200 OK
server: nginx
date: Wed, 08 Aug 2018 03:31:45 GMT
content-type: application/x-httpd-php5
cache-control: max-age=0
expires: Wed, 08 Aug 2018 03:31:44 GMT
X-Firefox-Spdy: h2
解决方案
推荐阅读
- typescript - 如何在 Typescript 中实现声明 .d.ts 文件
- angular - 路由权威角度
- typescript - 如果参数类型为“从不”,则 typescript ReturnType 为“any”
- node.js - 离子科尔多瓦构建类型'ModuleWithProviders'不是通用的
- macos - Mac 在两个终端中显示两个不同的环境变量值
- javascript - 我怎样才能让这个更短?
- azure - Azure Web 应用程序的域掩码是否有效
- python - 使用 Protocol 和 TypeVar 指定任意数据类的 Python 类型提示
- spring - Spring mongoDB 审计获取表上要更新的源数据
- list - 为什么论点的位置在缺点中很重要?