@Immutable public final class UserAgentWire extends Object implements Wire
This wire adds an extra HTTP header User-Agent
to the request,
if it's not yet provided, for example:
String html = new JdkRequest("http://goggle.com") .through(UserAgentWire.class) .fetch() .body();
An actual HTTP request will be sent with User-Agent
header with a value ReXSL-0.1/abcdef0 Java/1.6
(for example). It
is recommended to use this wire decorator when you're working with
third party RESTful services, to properly identify yourself and avoid
troubles.
The class is immutable and thread-safe.
Constructor and Description |
---|
UserAgentWire(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,
int connect,
int read)
Send request and return response.
|
public UserAgentWire(Wire wire)
wire
- Original wirepublic Response send(Request req, String home, String method, Collection<Map.Entry<String,String>> headers, InputStream content, int connect, int read) throws IOException
Wire
send
in interface Wire
req
- Requesthome
- URI to fetchmethod
- HTTP methodheaders
- Headerscontent
- HTTP bodyconnect
- The connect timeoutread
- The read timeoutIOException
- if failsCopyright © 2012–2021 jcabi.com. All rights reserved.