@Immutable public final class CookieOptimizingWire extends Object implements Wire
This wire compresses all provided Cookie
headers into one
and removes empty cookies, for example:
String html = new JdkRequest("http://goggle.com") .through(CookieOptimizingWire.class) .header(HttpHeaders.Cookie, "alpha=test") .header(HttpHeaders.Cookie, "beta=") .header(HttpHeaders.Cookie, "gamma=foo") .fetch() .body();
An actual HTTP request will be sent with just one Cookie
header with a value alpha=test; gamma=foo
.
It is highly recommended to use this wire decorator when you're working with cookies.
The class is immutable and thread-safe.
Constructor and Description |
---|
CookieOptimizingWire(Wire wire)
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 CookieOptimizingWire(@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
send
in interface Wire
req
- Requesthome
- URI to fetchmethod
- HTTP methodheaders
- Headerscontent
- HTTP bodyIOException
- if failsCopyright © 2012–2014 jcabi.com. All rights reserved.