|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.sal.core.net.HttpClientRequest
public class HttpClientRequest
HttpClient implementation of Request interface
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.atlassian.sal.api.net.Request |
|---|
Request.MethodType |
| Field Summary | |
|---|---|
static int |
MAX_REDIRECTS
The default number of redirects that will be followed. |
| Constructor Summary | |
|---|---|
HttpClientRequest(org.apache.commons.httpclient.HttpClient httpClient,
Request.MethodType methodType,
String url,
CertificateFactory certificateFactory,
UserManager userManager)
|
|
| Method Summary | ||
|---|---|---|
HttpClientRequest |
addAuthentication(Authenticator authenticator)
Adds generic Authenticator to the request. |
|
HttpClientRequest |
addBasicAuthentication(String username,
String password)
Adds basic authentication to the request. |
|
HttpClientRequest |
addHeader(String headerName,
String headerValue)
Adds the specified header to the request, not overwriting any previous value. |
|
HttpClientRequest |
addHeaders(String... params)
|
|
HttpClientRequest |
addRequestParameters(String... params)
Sets parameters of the request. |
|
HttpClientRequest |
addSeraphAuthentication(String username,
String password)
Adds seraph authentication to the request. |
|
HttpClientRequest |
addTrustedTokenAuthentication()
Adds TrustedTokenAuthentication to the request. |
|
HttpClientRequest |
addTrustedTokenAuthentication(String username)
Adds TrustedTokenAuthentication to the request. |
|
protected void |
configureProtocol(String url)
Configures the protocol for the underlying HttpClient. |
|
protected void |
configureProxy()
Configures the proxy for the underlying HttpClient. |
|
String |
execute()
Executes a request and if response is successful, returns response as a string. |
|
void |
execute(ResponseHandler<HttpClientResponse> responseHandler)
Executes the request. |
|
|
executeAndReturn(ReturningResponseHandler<HttpClientResponse,E> httpClientResponseResponseHandler)
Executes the request and returns a result value. |
|
protected com.google.common.collect.ImmutableList<HttpClientAuthenticator> |
getAuthenticators()
|
|
Map<String,List<String>> |
getHeaders()
|
|
int |
getMaxRedirects()
Get the maximum number of redirects allowed by this instance. |
|
Request.MethodType |
getMethodType()
|
|
protected org.apache.commons.httpclient.HttpMethod |
makeMethod()
|
|
HttpClientRequest |
setConnectionTimeout(int connectionTimeout)
Setting connection timeout in milliseconds. |
|
HttpClientRequest |
setEntity(Object entity)
Set an entity as the request body |
|
HttpClientRequest |
setFiles(List<RequestFilePart> files)
Sets file parts of the request. |
|
HttpClientRequest |
setFollowRedirects(boolean follow)
Sets whether the request should transparently follow a redirect from the server. |
|
HttpClientRequest |
setHeader(String headerName,
String headerValue)
Sets the specified header to the request, overwriting any previous value. |
|
HttpClientRequest |
setRequestBody(String requestBody)
Sets the body of the request. |
|
HttpClientRequest |
setRequestContentType(String requestContentType)
Sets Content-Type of the body of the request. |
|
HttpClientRequest |
setSoTimeout(int soTimeout)
Setting socket timeout in milliseconds. |
|
HttpClientRequest |
setUrl(String url)
|
|
static void |
shutdownStream(InputStream input)
Unconditionally close an InputStream. |
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_REDIRECTS
Raised the default in 2.10.1 to 20 as currently JIRA home page does 4 redirects.
NB prior to v2.10.1 one "redirect" was used up handling a successful request.,
Constant Field Values| Constructor Detail |
|---|
public HttpClientRequest(org.apache.commons.httpclient.HttpClient httpClient,
Request.MethodType methodType,
String url,
CertificateFactory certificateFactory,
UserManager userManager)
| Method Detail |
|---|
public HttpClientRequest setUrl(String url)
setUrl in interface Request<HttpClientRequest,HttpClientResponse>url - the url to request
public HttpClientRequest addAuthentication(Authenticator authenticator)
Request
addAuthentication in interface Request<HttpClientRequest,HttpClientResponse>authenticator - the authenticator to use for authentication
public HttpClientRequest addTrustedTokenAuthentication()
Request
addTrustedTokenAuthentication in interface Request<HttpClientRequest,HttpClientResponse>public HttpClientRequest addTrustedTokenAuthentication(String username)
Request
addTrustedTokenAuthentication in interface Request<HttpClientRequest,HttpClientResponse>username - The user to make the request with
public HttpClientRequest addBasicAuthentication(String username,
String password)
Request
addBasicAuthentication in interface Request<HttpClientRequest,HttpClientResponse>username - The user namepassword - The password
public HttpClientRequest addSeraphAuthentication(String username,
String password)
Request
addSeraphAuthentication in interface Request<HttpClientRequest,HttpClientResponse>username - The user namepassword - The password
protected com.google.common.collect.ImmutableList<HttpClientAuthenticator> getAuthenticators()
public HttpClientRequest setConnectionTimeout(int connectionTimeout)
Request
setConnectionTimeout in interface Request<HttpClientRequest,HttpClientResponse>connectionTimeout - The timeout in milliseconds
public HttpClientRequest setSoTimeout(int soTimeout)
Request
setSoTimeout in interface Request<HttpClientRequest,HttpClientResponse>soTimeout - the timeout in milliseconds
public HttpClientRequest setRequestBody(String requestBody)
RequestRequest.MethodType.POST and Request.MethodType.PUT can have a request body.
setRequestBody in interface Request<HttpClientRequest,HttpClientResponse>requestBody - the body of the request
public HttpClientRequest setFiles(List<RequestFilePart> files)
RequestRequest.MethodType.POST and Request.MethodType.PUT can have file parts.
setFiles in interface Request<HttpClientRequest,HttpClientResponse>files - the file parts, cannot be null.
public HttpClientRequest setEntity(Object entity)
Request
setEntity in interface Request<HttpClientRequest,HttpClientResponse>entity - the request entity to be marshalled, not null
public HttpClientRequest setRequestContentType(String requestContentType)
RequestRequest.MethodType.POST and Request.MethodType.PUT can have a request body.
setRequestContentType in interface Request<HttpClientRequest,HttpClientResponse>requestContentType - the contentType of the request
public HttpClientRequest addRequestParameters(String... params)
RequestRequest.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, etc
addRequestParameters in interface Request<HttpClientRequest,HttpClientResponse>params - parameters of the request in as name, value pairs
public HttpClientRequest addHeader(String headerName,
String headerValue)
Request
addHeader in interface Request<HttpClientRequest,HttpClientResponse>headerName - the header's nameheaderValue - the header's value
RequestFactory.supportsHeader()
public HttpClientRequest setHeader(String headerName,
String headerValue)
Request
setHeader in interface Request<HttpClientRequest,HttpClientResponse>headerName - the header's nameheaderValue - the header's value
RequestFactory.supportsHeader()public HttpClientRequest setFollowRedirects(boolean follow)
Request
setFollowRedirects in interface Request<HttpClientRequest,HttpClientResponse>follow - set this to false to have the request not transparently follow redirects.
public HttpClientRequest addHeaders(String... params)
public <E> E executeAndReturn(ReturningResponseHandler<HttpClientResponse,E> httpClientResponseResponseHandler)
throws ResponseException
Request
executeAndReturn in interface Request<HttpClientRequest,HttpClientResponse>httpClientResponseResponseHandler - Callback handler of the response.
ResponseProtocolException - If the server returned a malformed response
ResponseTimeoutException - If a connection timeout or read timeout occurred
ResponseTransportException - If an I/O error occurred in request transport
ResponseException - For all errors not otherwise specified
public void execute(ResponseHandler<HttpClientResponse> responseHandler)
throws ResponseException
Request
execute in interface Request<HttpClientRequest,HttpClientResponse>responseHandler - Callback handler of the response.
ResponseProtocolException - If the server returned a malformed response
ResponseTimeoutException - If a connection timeout or read timeout occurred
ResponseTransportException - If an I/O error occurred in request transport
ResponseException - For all errors not otherwise specifiedpublic static void shutdownStream(InputStream input)
InputStream.
Equivalent to InputStream.close(), except any exceptions will be ignored.
input - A (possibly null) InputStream
public String execute()
throws ResponseException
RequestResponse.getResponseBodyAsString()
execute in interface Request<HttpClientRequest,HttpClientResponse>ResponseStatusException - If the server returned a response that contained an error code
ResponseProtocolException - If the server returned a malformed response
ResponseTimeoutException - If a connection timeout or read timeout occurred
ResponseTransportException - If an I/O error occurred in request transport
ResponseException - For all errors not otherwise specifiedprotected org.apache.commons.httpclient.HttpMethod makeMethod()
protected void configureProxy()
protected void configureProtocol(String url)
public int getMaxRedirects()
public Map<String,List<String>> getHeaders()
getHeaders in interface Request<HttpClientRequest,HttpClientResponse>public Request.MethodType getMethodType()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||