URL中的许可方括号? [英] Are square brackets permitted in URLs?

查看:1427
本文介绍了URL中的许可方括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在方括号中允许的URL?

Are square brackets in URLs allowed?

我注意到,的Apache Commons的HttpClient (3.0.1)抛出一个IOException,wget和火狐但接受方括号。

I noticed that Apache commons HttpClient (3.0.1) throws an IOException, wget and Firefox however accept square brackets.

URL例如:

http://example.com/path/to/file[3].html

我的HTTP客户端遇到这样的网址,但我不知道是否修补code或抛出一个异常(因为它实际上应该是)。

My HTTP client encounters such URLs but I'm not sure whether to patch the code or to throw an exception (as it actually should be).

推荐答案

RFC 3986 状态

由互联网标识的主机
  协议文字地址,第6版
  [RFC3513]或更高版本,是杰出的
  通过封闭内的IP字面
  方括号([和])。这个
  是唯一的地方,方括号
  字符允许在URI
  语法。​​

A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax.

所以,你不应该看到这样的URI在理论上野外,因为他们应该EN codeD到达。

So you should not be seeing such URI's in the wild in theory, as they should arrive encoded.

这篇关于URL中的许可方括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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