- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个关于 URL 的问题:
我读过 RFC 3986并且仍然对一个 URL 有疑问:
If a URI contains an authority component, then the path component
must either be empty or begin with a slash ("/") character. If a URI does not contain an authority component, then the path cannot begin
with two slash characters ("//"). In addition, a URI reference
(Section 4.1) may be a relative-path reference, in which case the
first path segment cannot contain a colon (":") character. The ABNF
requires five separate rules to disambiguate these cases, only one of which will match the path substring within a given URI reference. We use the generic term "path component" to describe the URI substring
matched by the parser to one of these rules.
我知道,//server.com:80/path/info
是有效的(它是模式相对 URL)
我也知道 http://server.com:80/path//info
是有效的。
但我不确定下面的是否有效:
http://server.com:80//path/info
我的问题背后的问题是,当由 URI http:/创建时,cookie 不会发送到
限制为 http://server.com:80//path/info
/server.com:80/path/info/path
最佳答案
参见 url with multiple forward slashes, does it break anything? , Are there any downsides to using double-slashes in URLs? , What does the double slash mean in URLs?和 RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax .
共识:浏览器将按原样处理请求,不会更改请求。 /
字符是路径分隔符,但作为路径段定义为:
path-abempty = *( "/" segment )
segment = *pchar
表示 http://example.com/
之后的斜杠可以直接跟另一个斜杠,无限次。服务器可能会忽略它,但浏览器不会,如您所知。
短语:
If a URI does not contain an authority component, then the path cannot beginwith two slash characters ("//").
允许protocol-relative URLs ,但在这种情况下明确说明可能不存在权限(server.com:80
在您的示例中)。
所以:是的,它是有效的,不,不要使用它。
关于http - 路径部分中带有//的 URL 是否有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20523318/
我是一名优秀的程序员,十分优秀!