重复HTTP GET查询键的权威位置 [英] Authoritative position of duplicate HTTP GET query keys

查看:90
本文介绍了重复HTTP GET查询键的权威位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到有关HTTP GET查询字符串重复字段的行为的权威信息,例如

I am having trouble on finding authoritative information about the behavior with HTTP GET query string duplicate fields, like

http://example.com/page?field=foo&field=bar 

,特别是如果订单是保持与否。大多数面向Web的语言产生一个包含与关键字段相关联的foo和bar的数组,但我想知道是否存在关于这一点的权威声明(例如在RFC上)。 RFC 3986 的部分 3.4。查询,它引用了键=值对,但没有说明如何解释顺序和重复字段等。这是有道理的,因为它是后端依赖的,而不是在RFC的范围内...

and in particular if the order is kept or not. Most web-oriented languages produce an array containing both foo and bar associated to a key "field", but I would like to know if authoritative statement exist (e.g. on a RFC) about this point. RFC 3986 has a section 3.4. Query, which refers to key=value pairs, but nothing is said on how to interpret order and duplicate fields and so on. This makes sense, since it's backend dependent, and not in the scope of that RFC...

虽然存在事实上的标准,但我希望看到它的权威来源,只是出于好奇。

Although a de-facto standard exists, I'd like to see an authoritative source for it, just out of curiosity.

推荐答案

上没有规范。你可以做自己喜欢的事情。

There is no spec on this. You may do what you like.

典型的方法包括:先给定,最后给定,所有数组,字符串连接用逗号 - 所有。

Typical approaches include: first-given, last-given, array-of-all, string-join-with-comma-of-all.

假设原始请求是:

GET /blog/posts?tag=ruby&tag=rails HTTP/1.1
Host: example.com

然后, request.query ['tag'] 应该产生各种选项,具体取决于语言或框架:

Then there are various options for what request.query['tag'] should yield, depending on the language or the framework:

request.query['tag'] => 'ruby'
request.query['tag'] => 'rails'
request.query['tag'] => ['ruby', 'rails']
request.query['tag'] => 'ruby,rails'

这篇关于重复HTTP GET查询键的权威位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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