Package com.jcabi.http.wire
Class UserAgentWire
java.lang.Object
com.jcabi.http.wire.UserAgentWire
- All Implemented Interfaces:
Wire
Wire with default user agent.
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.
- Since:
- 0.10
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsend(Request req, String home, String method, Collection<Map.Entry<String, String>> headers, InputStream content, int connect, int read) Send request and return response.
-
Constructor Details
-
UserAgentWire
Public ctor.- Parameters:
wire- Original wire
-
-
Method Details
-
send
public Response send(Request req, String home, String method, Collection<Map.Entry<String, String>> headers, InputStream content, int connect, int read) throws IOExceptionDescription copied from interface:WireSend request and return response.- Specified by:
sendin 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
-