HTTP内容的大小写问题

用curl模拟http请求大家都会,对于内容也都知道,但是问几个问题
curl http://127.0.0.1/ -H “UA:Curl” -v和curl http://127.0.0.1/ -H “UA:curl” -v一样吗?
curl http://127.0.0.1/ -H “UA:Curl” -v和curl http://127.0.0.1/ -H “Ua:Curl” -v一样吗?
curl http://127.0.0.1/ -X POST -v和curl http://127.0.0.1/ -X post -v 一样吗?


可能就要犹豫了。今天正好翻了rfc,找到了答案。
RFC2616是最早的http1.0的规范,其中规定

  • Field names are case-insensitive,

现在rfc2616已经被rfc7230-7237取代,查看了这两个RFC。

rfc7230中3.1.1. Request Line中明确说明:

  • The request method is case-sensitive.
  • Recipients of an invalid request-line SHOULD respond with either a 400 (Bad Request) error or a 301 (Moved Permanently) redirect with the request-target properly encoded. A recipient SHOULD NOT attempt to autocorrect and then process the request without a redirect, since the invalid request-line might be deliberately crafted to bypass security filters along the request chain.

上面意思是说请求行里的请求方法是大小写敏感的,,收到不认识的请求方法时,应该返回400或者301重定向,而不应该修改请求方法然后继续处理。

rfc7231中4. Request Methods中说明

  • By convention, standardized methods are defined in all-uppercase US-ASCII letters.
  • All general-purpose servers MUST support the methods GET and HEAD. All other methods are OPTIONAL.

两句意思是方法应该是全大写ASCII字母,所有通用服务器必须支持GET和head.其他方法是可选的。


现在知道开始问题的答案了吧

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值