Java – httpclient API of sethttprequestretryhandler

HTTP commons client 4.12 tutorial section on exception handling clearly indicates that it should be possible to set the request retry handler by performing the following operations

httpclient. setHttpRequestRetryHandler(myRetryHandler);

I tried it in eclipse, which reports that httpclient does not have such a method It recommends that I convert the client to AbstractHttpClient and then call it. Sethttprequestretryhandler, as follows:

((AbstractHttpClient)httpclient). setHttpRequestRetryHandler(myRetryHandler);

Then my code works, but the difference between documentation and API makes me wonder if I'm doing something I shouldn't do

Is the document wrong or me?

Solution

You are absolutely right This document uses the specific defaulthttpclient (it is a subclass of abstracthttpclient, so it has the sethttprequestretryhandler () method

When you are programming and programming the httpclient interface correctly (unfortunately, this method is not exposed), you must be the annoying actor

It seems that the Apache team decided to keep the httpclient interface super clean at the cost of client code:-(

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>