Package com.jcabi.http.wire
Class OneMinuteWire
- java.lang.Object
-
- com.jcabi.http.wire.OneMinuteWire
-
- All Implemented Interfaces:
Wire
@Immutable public final class OneMinuteWire extends Object implements Wire
Wire that throws anIOException
if a request takes longer than a minute.It's recommended to use this decorator in production, in order to avoid stuck requests:
String html = new JdkRequest("http://goggle.com") .through(OneMinuteWire.class) .header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN) .fetch() .body();
The class is immutable and thread-safe.
- Since:
- 0.10
-
-
Constructor Summary
Constructors Constructor Description OneMinuteWire(Wire wire)
Public ctor.
-
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
-
OneMinuteWire
public OneMinuteWire(Wire wire)
Public ctor.- Parameters:
wire
- Original wire
-
-
Method Detail
-
send
@Timeable(limit=1, unit=MINUTES) 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
-
-