Apache 上的内容类型:JSON 的 http 请求是否需要任何特定的处理程序?
我的请求标头:
GET /abs/ad-content/id/1277954_1 HTTP/1.1
Host: myhost.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: application/json, text/javascript, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/json; charset=utf-8
X-Requested-With: XMLHttpRequest
请注意:
Content-Type: application/json; charset=utf-8
但我的服务器似乎无法处理它。
$request->getHeader('Content-Type');
服务器返回空。
我是否需要添加一些处理程序/Mime 类型才能使其正常工作?
编辑:此标头存在于我的 Windows Apache 本地主机上,但在 Bluehost Apache 共享服务器上缺失。
My request header :
GET /abs/ad-content/id/1277954_1 HTTP/1.1
Host: myhost.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: application/json, text/javascript, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/json; charset=utf-8
X-Requested-With: XMLHttpRequest
please note:
Content-Type: application/json; charset=utf-8
But it seems my server can not process it.
$request->getHeader('Content-Type');
is returned empty by server.
Do I need to add some handler/Mime Type to get it work?
Edit: This header is present on my windows Apache localhost but missing on Bluehost Apache shared server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,GET 请求不会有正文因为它是一种安全方法,仅供参考检索:
所以我猜 Apache 或您使用的编程语言/框架会跳过/省略任何 实体标头字段,因为它不需要任何包含实体。
In general, it is not expected that a GET request has a body as it is meant to be a safe method only for information retrieval:
So I guess Apache or the programming language/framework you are using skips/omits any entity header fields as it doesn’t expect any containing entity.