Package com.jcabi.http.request
Class BaseRequest
- java.lang.Object
-
- com.jcabi.http.request.BaseRequest
-
-
Constructor Summary
Constructors Constructor Description BaseRequest(Wire wre, String uri)Public ctor.BaseRequest(Wire wre, String uri, Iterable<Map.Entry<String,String>> headers, String method, byte[] body)Public ctor.BaseRequest(Wire wre, String uri, Iterable<Map.Entry<String,String>> headers, String method, byte[] body, int cnct, int rdd)Public ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestBodybody()Get request body.Responsefetch()Execute it with a specified HTTP method.Responsefetch(InputStream stream)Execute this request using the content provided by theInputStreambeing passed as the request body.Requestheader(String name, Object value)Set request header.Requestmethod(String method)Use this method.RequestBodymultipartBody()Get multipart form (multipart/form-data) body.Requestreset(String name)Remove all headers with this name.Requestthrough(Wire wre)Send it through a decoratingWire.<T extends Wire>
Requestthrough(Class<T> type, Object... args)Send it through a decoratingWire.Requesttimeout(int cnct, int rdd)Use this timeout values.StringtoString()RequestURIuri()Get destination URI.
-
-
-
Constructor Detail
-
BaseRequest
public BaseRequest(Wire wre, String uri)
Public ctor.- Parameters:
wre- Wireuri- The resource to work with
-
BaseRequest
public BaseRequest(Wire wre, String uri, Iterable<Map.Entry<String,String>> headers, String method, byte[] body)
Public ctor.- Parameters:
wre- Wireuri- The resource to work withheaders- Headersmethod- HTTP methodbody- HTTP request body
-
BaseRequest
public BaseRequest(Wire wre, String uri, Iterable<Map.Entry<String,String>> headers, String method, byte[] body, int cnct, int rdd)
Public ctor.- Parameters:
wre- Wireuri- The resource to work withheaders- Headersmethod- HTTP methodbody- HTTP request bodycnct- Connect timeout for http connectionrdd- Read timeout for http connection
-
-
Method Detail
-
uri
public RequestURI uri()
Description copied from interface:RequestGet destination URI.
-
header
public Request header(String name, Object value)
Description copied from interface:RequestSet request header.
-
reset
public Request reset(String name)
Description copied from interface:RequestRemove all headers with this name.
-
body
public RequestBody body()
Description copied from interface:RequestGet request body.
-
multipartBody
public RequestBody multipartBody()
Description copied from interface:RequestGet multipart form (multipart/form-data) body.- Specified by:
multipartBodyin interfaceRequest- Returns:
- New altered request
-
method
public Request method(String method)
Description copied from interface:RequestUse this method.
-
timeout
public Request timeout(int cnct, int rdd)
Description copied from interface:RequestUse this timeout values.
-
fetch
public Response fetch() throws IOException
Description copied from interface:RequestExecute it with a specified HTTP method.- Specified by:
fetchin interfaceRequest- Returns:
- Response
- Throws:
IOException- If fails to fetch HTTP request
-
fetch
public Response fetch(InputStream stream) throws IOException
Description copied from interface:RequestExecute this request using the content provided by theInputStreambeing passed as the request body. Note that the request MUST have an empty body when this method is being invoked, or it will throw anIllegalStateException.- Specified by:
fetchin interfaceRequest- Parameters:
stream- The input stream to use- Returns:
- Response
- Throws:
IOException- If fails to fetch HTTP request
-
through
public <T extends Wire> Request through(Class<T> type, Object... args)
Description copied from interface:RequestSend it through a decoratingWire.
-
through
public Request through(Wire wre)
Description copied from interface:RequestSend it through a decoratingWire.
-
-