T
- the type of request used for method chainingpublic interface Request<T extends Request<?,?>,RESP extends Response>
execute(ResponseHandler)
.Modifier and Type | Interface and Description |
---|---|
static class |
Request.MethodType
Represents type of network request
|
Modifier and Type | Method and Description |
---|---|
T |
addBasicAuthentication(String hostname,
String username,
String password)
Adds basic authentication to the request.
|
T |
addHeader(String headerName,
String headerValue)
Adds the specified header to the request, not overwriting any previous value.
|
T |
addRequestParameters(String... params)
Sets parameters of the request.
|
String |
execute()
Executes a request and if response is successful, returns response as a string.
|
void |
execute(ResponseHandler<? super RESP> responseHandler)
Executes the request.
|
<RET> RET |
executeAndReturn(ReturningResponseHandler<? super RESP,RET> responseHandler)
Executes the request and returns a result value.
|
Map<String,List<String>> |
getHeaders() |
T |
setConnectionTimeout(int connectionTimeout)
Setting connection timeout in milliseconds.
|
T |
setEntity(Object entity)
Set an entity as the request body
|
T |
setFiles(List<RequestFilePart> files)
Sets file parts of the request.
|
T |
setFollowRedirects(boolean follow)
Sets whether the request should transparently follow a redirect from the server.
|
T |
setHeader(String headerName,
String headerValue)
Sets the specified header to the request, overwriting any previous value.
|
T |
setRequestBody(String requestBody)
Sets the body of the request.
|
T |
setRequestBody(String requestBody,
String contentType)
Sets the body of the request.
|
T |
setSoTimeout(int soTimeout)
Setting socket timeout in milliseconds.
|
T |
setUrl(String url) |
T setConnectionTimeout(int connectionTimeout)
connectionTimeout
- The timeout in millisecondsT setSoTimeout(int soTimeout)
soTimeout
- the timeout in millisecondsT setRequestBody(String requestBody)
Request.MethodType.POST
and Request.MethodType.PUT
can have a request body.requestBody
- the body of the requestT setRequestBody(String requestBody, String contentType)
Request.MethodType.POST
and Request.MethodType.PUT
can have a request body.requestBody
- the body of the requestcontentType
- the contentType of the requestT setFiles(List<RequestFilePart> files)
Request.MethodType.POST
and Request.MethodType.PUT
can have file parts.files
- the file parts, cannot be null.IllegalArgumentException
- if the method of this request is not a POST or PUT or files is NULL.IllegalStateException
- if the request body for this request has already been set.T setEntity(Object entity)
entity
- the request entity to be marshalled, not nullT addRequestParameters(String... params)
Request.MethodType.POST
can have parameters.
For other requests include parameters in url. This method accepts an even number of arguments, in form of name, value, name, value, name, value, etcparams
- parameters of the request in as name, value pairsT addBasicAuthentication(String hostname, String username, String password)
username
- The user namepassword
- The passwordT addHeader(String headerName, String headerValue)
headerName
- the header's nameheaderValue
- the header's valueRequestFactory.supportsHeader()
T setHeader(String headerName, String headerValue)
headerName
- the header's nameheaderValue
- the header's valueRequestFactory.supportsHeader()
T setFollowRedirects(boolean follow)
follow
- set this to false to have the request not transparently follow redirects.Map<String,List<String>> getHeaders()
void execute(ResponseHandler<? super RESP> responseHandler) throws ResponseException
responseHandler
- Callback handler of the response.ResponseProtocolException
- If the server returned a malformed responseResponseTimeoutException
- If a connection timeout or read timeout occurredResponseTransportException
- If an I/O error occurred in request transportResponseException
- For all errors not otherwise specifiedString execute() throws ResponseException
Response.getResponseBodyAsString()
ResponseStatusException
- If the server returned a response that contained an error codeResponseProtocolException
- If the server returned a malformed responseResponseTimeoutException
- If a connection timeout or read timeout occurredResponseTransportException
- If an I/O error occurred in request transportResponseException
- For all errors not otherwise specified<RET> RET executeAndReturn(ReturningResponseHandler<? super RESP,RET> responseHandler) throws ResponseException
responseHandler
- Callback handler of the response.ResponseProtocolException
- If the server returned a malformed responseResponseTimeoutException
- If a connection timeout or read timeout occurredResponseTransportException
- If an I/O error occurred in request transportResponseException
- For all errors not otherwise specifiedCopyright © 2015 Atlassian. All rights reserved.
View cookie preferences