【问题标题】:Implement HttpRequestRetryHandler and RequestBuilder in httpclient5在httpclient5中实现HttpRequestRetryHandler和RequestBuilder
【发布时间】:2021-01-16 16:02:40
【问题描述】:

我计划更新我的项目以使用 httpclient5。
之后我在 httpclient5(5.0、5.01 和 5.0.2)中认识到,它们不再具有 HttPRequestRetryHandler 和 RequestBuilder 类。
有什么办法或更新不在 http5 中使用这些类,还是我们有一些具有相同功能的替代品?

【问题讨论】:

    标签: java httpclient apache-httpclient-5.x


    【解决方案1】:
    1. 请改用org.apache.hc.client5.http.HttpRequestRetryStrategy

    2. org.apache.hc.core5.http.io.support.ClassicRequestBuilder 与经典传输一起使用,将org.apache.hc.core5.http.nio.support.AsyncRequestBuilder 与异步传输一起使用。

    通常,从 Apache HttpClient 4.5.x 迁移到 Apache HttpClient 5.x 时,此资源可能很有用

    https://ok2c.github.io/httpclient-migration-guide/

    【讨论】:

    • 它工作完美,除了 ClassicRequestBuilder 没有 setConfig(method)。你有什么建议吗,ok2c?
    • 请改用HttpClientContext#setRequestConfig
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多