@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.
|
public UserAgentWire(@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, byte[] 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.