Package com.jcabi.http.wire
Class RetryWire
- java.lang.Object
-
- com.jcabi.http.wire.RetryWire
-
- All Implemented Interfaces:
Wire
@Immutable public final class RetryWire extends Object implements Wire
Wire that retries a few times before giving up and throwing exception.This wire retries again (at least three times) if an original one throws
IOException
:String html = new JdkRequest("http://goggle.com") .through(RetryWire.class) .header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN) .fetch() .body();
Since version 1.9 this wire retries also if HTTP status code is between 500 and 599.
The class is immutable and thread-safe.
- Since:
- 0.10
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Response
send(Request req, String home, String method, Collection<Map.Entry<String,String>> headers, InputStream content, int connect, int read)
Send request and return response.
-
-
-
Constructor Detail
-
RetryWire
public RetryWire(Wire wire)
Public ctor.- Parameters:
wire
- Original wire
-
-
Method Detail
-
send
public Response send(Request req, String home, String method, Collection<Map.Entry<String,String>> headers, InputStream content, int connect, int read) throws IOException
Description copied from interface:Wire
Send request and return response.- Specified by:
send
in interfaceWire
- Parameters:
req
- Requesthome
- URI to fetchmethod
- HTTP methodheaders
- Headerscontent
- HTTP bodyconnect
- The connect timeoutread
- The read timeout- Returns:
- Response obtained
- Throws:
IOException
- if fails
-
-