Package com.jcabi.http.wire
Class CookieOptimizingWire
- java.lang.Object
-
- com.jcabi.http.wire.CookieOptimizingWire
-
- All Implemented Interfaces:
Wire
@Immutable public final class CookieOptimizingWire extends Object implements Wire
Wire that compresses cookies before sending.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 valuealpha=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.
- Since:
- 0.10
- See Also:
- RFC 2965 "HTTP State Management Mechanism"
-
-
Constructor Summary
Constructors Constructor Description CookieOptimizingWire(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
-
CookieOptimizingWire
public CookieOptimizingWire(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
-
-