commons-httpclient-3.1 中的 URIUtil.encodePath 发生了什么?
我想做问题 724043 中描述的操作,即对以下路径组件进行编码一个 URI。建议这样做的类是 URIUtil。不幸的是,该类似乎已从最新版本的 HttpClient 中消失。 HttpClient 4.1 中类似命名的类, URIUtils,不提供相同的功能。这个类/方法是否已转移到我不知道的其他库中,或者它已经消失了?我最好只是将 3.1 版本中的类复制到我的代码中还是有更简单的方法?
I want to do what's described in question 724043, namely encode the path components of a URI. The class recommended to do that is URIUtil from Commons HttpClient 3.1. Unfortunately, that class seems to have disappeared from the most recent version of HttpClient. A similarly named class from HttpClient 4.1, URIUtils, doesn't provide the same functionality. Has this class/method been moved to some other library that I'm not aware of or is it just gone? Am I best off just copying the class from the 3.1 release into my code or is there a simpler way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该模块的维护者已规定您应该使用标准 JDK URI 类:
因此,最简单的方法是查看 3.1 版本中的encodePath 源代码,并在您自己的代码中复制它的功能(或者只是将方法/类复制到您的代码库中)。
或者您可以对您提到的问题采用已接受的答案(但似乎您必须首先将 URL 分成几部分):
The maintainers of the module have decreed that you should use the standard JDK URI class instead:
So, the easiest is to look at the source of encodePath from the 3.1 release and duplicate what it does in your own code (or just copy the method/class into your codebase).
Or you could go with the accepted answer on the question you referred to (but it seems you have to break the URL into parts first):
这可以使用 httpclient-4.X () 中的 org.apache.http.client.utils.URIBuilder 实用程序来实现,如下所示。
This can be achieved using
org.apache.http.client.utils.URIBuilder
utility in httpclient-4.X () as follows.您可以使用 标准 JDK 函数,例如
You can use Standard JDK functions, e.g.