java 从 HttpClient 3.x 迁移到 4.x

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6615394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 16:38:07  来源:igfitidea点击:

Migrating from HttpClient 3.x to 4.x

javaapache-commons-httpclientapache-httpclient-4.x

提问by Cincinnati Joe

We have some code written using commons-httpclient-3.1 that needs to be converted to 4.1. I'm only somewhat familiar with this and am reading the 4.1 httpclient tutorialnow.

我们有一些使用 commons-httpclient-3.1 编写的代码需要转换为 4.1。我只是对此有点熟悉,现在正在阅读 4.1 httpclient 教程

I see a couple of posts here (e.g. Converting from HttpClient 3 to 4but that's about a specific construct). Seems like there should be some docs/examples somewhere showing how to upgrade usage of 3.x to 4.x ?

我在这里看到了几篇文章(例如从 HttpClient 3 转换为 4,但那是关于特定构造的)。似乎应该有一些文档/示例显示如何将 3.x 的使用升级到 4.x ?

One specific example: replacing use of org.apache.commons.httpclient.HttpState

一个具体的例子:替换使用 org.apache.commons.httpclient.HttpState

回答by CrackerHyman9

I would replace the library jar(s) in your IDE and look for compiler errors to start with. You may wish to go back and check all usages to ensure they are used the same way, and parameters remain as expected (hopefully they didn't switch things around).

我会在您的 IDE 中替换库 jar(s) 并查找编译器错误以开始。您可能希望返回并检查所有用法以确保它们以相同的方式使用,并且参数保持如预期(希望它们没有改变)。

Is there a specific piece of code you are unsure how to get working with 4.1?

是否有一段特定的代码您不确定如何使用 4.1?