查询字符串键是否区分大小写? [英] Are query string keys case sensitive?

查看:182
本文介绍了查询字符串键是否区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个这样的网址:

Suppose I have a url like this:

http://www.example.com?key=123&KEY=198

那将是

request.querystring("key")

and 

request.querystring("KEY")

我有点困惑.

推荐答案

用于URI的RFC 说:

6.2.2.1.案例规范化

6.2.2.1. Case Normalization

当URI使用通用语法的组件时,组件语法等效规则始终适用;也就是说,方案和主机不区分大小写,因此应规范化为小写.例如,URI等效于 http://www.example.com/.

When a URI uses components of the generic syntax, the component syntax equivalence rules always apply; namely, that the scheme and host are case-insensitive and therefore should be normalized to lowercase. For example, the URI is equivalent to http://www.example.com/.

除非该方案另有明确规定,否则假定其他通用语法组件区分大小写(请参阅第6.2.3节).

The other generic syntax components are assumed to be case-sensitive unless specifically defined otherwise by the scheme (see Section 6.2.3).

请注意,方案(此处为"http"),主机(服务器名称)不区分大小写,但无论如何都应使用小写字母.其余的区分大小写,除非您使用不同的方案明确表明它应该不区分大小写.

Note that scheme ("http" here), host (server name) are case-insensitive but should be in lowercase anyway. The rest is case-sensitive unless you're using a different scheme that explicitly says it should be insensitive.

根据规范,在所有基于http的URI中,key和KEY是不同的东西.

So key and KEY are different things in all http-based URIs according to the spec.

@Nicholas在假设权限定义了接受的内容方面是部分错误的,这对于自定义方案和定义自己的URI的权限来说是正确的,但是http是每个人都遵循的定义明确的规范(或者您可能拥有具有以下条件的http查询,例如,用竖线字符作为分隔符.想象一下那里的混乱!)

@Nicholas is partly wrong in assuming that the authority defines what it accepts, that's true for custom schemes and authorities that define their own URIs, but http is a well-defined spec that everyone conforms to (or you could have http queries that have, say, the pipe character as a delimiter. Imagine the chaos there!)

HTTP的RFC规范说:

方案和主机不区分大小写,通常在 小写所有其他组件在区分大小写的情况下进行比较 方式.除保留"集中的字符以外的其他字符是 等同于其百分比编码的八位位组:正常形式为 不对它们进行编码(请参阅[RFC3986]的2.1和2.2节).

The scheme and host are case-insensitive and normally provided in lowercase; all other components are compared in a case-sensitive manner. Characters other than those in the "reserved" set are equivalent to their percent-encoded octets: the normal form is to not encode them (see Sections 2.1 and 2.2 of [RFC3986]).

因此,由HTTP方案的规范定义的URI的查询部分区分大小写.如果Microsoft对于查询字符串具有不区分大小写的解析器,则它不符合规范.并不是说我觉得这种挑剔的程度真的很重要.

So the query part of the URI as defined by the spec for the HTTP scheme is case-sensitive. If Microsoft has a case-insensitive parser for query strings, its not conforming to the spec. Not that I guess this level of pickiness really matters much.

这篇关于查询字符串键是否区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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