Package com.jcabi.http.wire
Class BasicAuthWire
- java.lang.Object
-
- com.jcabi.http.wire.BasicAuthWire
-
- All Implemented Interfaces:
Wire
@Immutable public final class BasicAuthWire extends Object implements 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:[email protected]") .through(BasicAuthWire.class) .fetch() .body();
In this example, an additional HTTP header
Authorization
will be added with a valueBasic amVmZjoxMjM0NQ==
.The class is immutable and thread-safe.
- Since:
- 0.10
- See Also:
- RFC 2617 "HTTP Authentication: Basic and Digest Access Authentication"
-
-
Constructor Summary
Constructors Constructor Description BasicAuthWire(Wire wire)
Public ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
BasicAuthWire
public BasicAuthWire(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:Wire
Send request and return response.- Specified by:
send
in 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
-
-