Package com.jcabi.http.request
Class JdkRequest
java.lang.Object
com.jcabi.http.request.JdkRequest
- All Implemented Interfaces:
Request
Implementation of
Request, based on JDK.
This implementation will be enough in most situations. However,
sometimes you may need better tuning or an ability to fetch custom
HTTP methods (JDK doesn't support PATCH, for example). In this case,
use ApacheRequest.
The class is immutable and thread-safe.
- Since:
- 0.8 // @checkstyle ClassDataAbstractionCoupling (500 lines)
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionJdkRequest(String uri) Public ctor.JdkRequest(URI uri) Public ctor.JdkRequest(URL url) Public ctor. -
Method Summary
Modifier and TypeMethodDescriptionbody()Get request body.fetch()Execute it with a specified HTTP method.fetch(InputStream stream) Execute this request using the content provided by theInputStreambeing passed as the request body.Set request header.Use this method.Get multipart form (multipart/form-data) body.Remove all headers with this name.Send it through a decoratingWire.Send it through a decoratingWire.timeout(int connect, int read) Use this timeout values.uri()Get destination URI.
-
Constructor Details
-
JdkRequest
Public ctor.- Parameters:
url- The resource to work with
-
JdkRequest
Public ctor.- Parameters:
uri- The resource to work with
-
JdkRequest
Public ctor.- Parameters:
uri- The resource to work with
-
-
Method Details
-
uri
Description copied from interface:RequestGet destination URI. -
header
Description copied from interface:RequestSet request header. -
reset
Description copied from interface:RequestRemove all headers with this name. -
body
Description copied from interface:RequestGet request body. -
multipartBody
Description copied from interface:RequestGet multipart form (multipart/form-data) body.- Specified by:
multipartBodyin interfaceRequest- Returns:
- New altered request
-
method
Description copied from interface:RequestUse this method. -
timeout
Description copied from interface:RequestUse this timeout values. -
fetch
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
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
Description copied from interface:RequestSend it through a decoratingWire. -
through
Description copied from interface:RequestSend it through a decoratingWire.
-