Package com.jcabi.http.wire
Class UserAgentWire
- java.lang.Object
-
- com.jcabi.http.wire.UserAgentWire
-
- All Implemented Interfaces:
Wire
@Immutable public final class UserAgentWire extends Object implements Wire
Wire with default user agent.This wire adds an extra HTTP header
User-Agentto 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-Agentheader with a valueReXSL-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:
- RFC 2616 section 14.43 "User-Agent"
-
-
Constructor Summary
Constructors Constructor Description UserAgentWire(Wire wire)Public ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Responsesend(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
-
UserAgentWire
public UserAgentWire(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: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
-
-