Package com.jcabi.http.wire
Class RetryWire
java.lang.Object
com.jcabi.http.wire.RetryWire
- All Implemented Interfaces:
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsend(Request req, String home, String method, Collection<Map.Entry<String, String>> hdrs, InputStream cont, int conn, int read) Send request and return response.
-
Constructor Details
-
RetryWire
Public ctor.- Parameters:
wire- Original wire
-
-
Method Details
-
send
public Response send(Request req, String home, String method, Collection<Map.Entry<String, String>> hdrs, InputStream cont, int conn, int read) throws IOExceptionDescription copied from interface:WireSend request and return response.- Specified by:
sendin interfaceWire- Parameters:
req- Requesthome- URI to fetchmethod- HTTP methodhdrs- Headerscont- HTTP bodyconn- The connect timeoutread- The read timeout- Returns:
- Response obtained
- Throws:
IOException- if fails
-