Package com.jcabi.http.wire
Class BasicAuthWire
java.lang.Object
com.jcabi.http.wire.BasicAuthWire
- All Implemented Interfaces:
Wire
Wire with HTTP basic authentication based on user info of URI.
This wire converts user info from URI into
"Authorization" HTTP header, for example:
String html = new JdkRequest("http://jeff:12345@example.com")
.through(BasicAuthWire.class)
.fetch()
.body();
In this example, an additional HTTP header Authorization
will be added with a value Basic amVmZjoxMjM0NQ==.
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
-
BasicAuthWire
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
-