@Immutable public final class CachingWire extends Object implements Wire
This decorator can be used when you want to avoid duplicate GET requests to load-sensitive resources, for example:
String html = new JdkRequest("http://goggle.com") .through(CachingWire.class) .header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN) .fetch() .body();
Since 1.5, you can also configure it to flush the entire cache on certain request URI's, for example:
new JdkRequest(uri) .through(CachingWire.class, "GET /save/.*") .uri().path("/save/123").back() .fetch();
The regular expression provided will be used against a string constructed as an HTTP method, space, path of the URI together with query part.
The class is immutable and thread-safe.
Constructor and Description |
---|
CachingWire(Wire wire)
Public ctor.
|
CachingWire(Wire wire,
String flsh)
Public ctor.
|
Modifier and Type | Method and Description |
---|---|
Response |
send(Request req,
String home,
String method,
Collection<Map.Entry<String,String>> headers,
InputStream content)
Send request and return response.
|
public CachingWire(@NotNull(message="wire can\'t be NULL") Wire wire)
wire
- Original wirepublic Response send(Request req, String home, String method, Collection<Map.Entry<String,String>> headers, InputStream content) throws IOException
Wire
send
in interface Wire
req
- Requesthome
- URI to fetchmethod
- HTTP methodheaders
- Headerscontent
- HTTP bodyIOException
- if failsCopyright © 2012–2014 jcabi.com. All rights reserved.