public class TakHttpClient
extends java.lang.Object
Constructor and Description |
---|
TakHttpClient(java.lang.String url)
Setup HTTP client.
|
TakHttpClient(java.lang.String baseUrl,
org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory)
Setup HTTP client with a given sslSocketFactory.
|
TakHttpClient(java.lang.String baseUrl,
org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory,
int connectTimeout,
int soTimeout)
Setup HTTP client with a given sslSocketFactory and custom timeout values.
|
TakHttpClient(java.lang.String url,
java.lang.String connectString)
Setup HTTP client.
|
Modifier and Type | Method and Description |
---|---|
void |
addBasicAuthentication(HttpRequestBase request)
Add Basic Auth for HTTP, not HTTPS (which typically uses client certificates)
|
void |
addBasicAuthentication(HttpRequestBase request,
AtakAuthenticationCredentials credentials)
Add Basic Auth for the request using the credentials provided
|
TakHttpResponse |
execute(HttpRequestBase request) |
TakHttpResponse |
execute(HttpRequestBase request,
AtakAuthenticationCredentials credentials) |
TakHttpResponse |
execute(HttpRequestBase request,
boolean bAddAuth) |
java.lang.String |
get(java.lang.String url)
Perform an HTTP GET on the URL
|
java.lang.String |
get(java.lang.String url,
java.lang.String verify)
Perform an HTTP GET on the URL
|
java.lang.String |
get(java.lang.String url,
java.lang.String verify,
java.lang.String accept) |
java.lang.String |
get(java.lang.String url,
java.lang.String verify,
java.lang.String accept,
java.lang.String acceptEncoding)
Perform an HTTP GET on the URL
|
java.lang.String |
getGZip(java.lang.String url,
java.lang.String verify)
Perform an HTTP GET on the URL, support GZip
|
java.lang.String |
getGZip(java.lang.String url,
java.lang.String verify,
java.lang.String accept)
Perform an HTTP GET on the URL, support GZip
|
static TakHttpClient |
GetHttpClient(org.apache.http.conn.ssl.SSLSocketFactory factory,
java.lang.String url)
Creates an HttpClient using specified socket factory
|
static TakHttpClient |
GetHttpClient(java.lang.String url)
Creates an HttpClient and proper TAK Server base URL
Uses internally stored certificates
|
static TakHttpClient |
GetHttpClient(java.lang.String url,
java.lang.String connectString)
Creates an HttpClient and proper TAK Server base URL
Uses internally stored certificates
|
java.lang.String |
getUrl()
Get the TAK (Server) base URL
|
java.lang.String |
getUrl(java.lang.String path)
Get the TAK (Server) URL for specified path
|
boolean |
head(java.lang.String url)
Perform HTTP HEAD on the URL
|
void |
shutdown() |
boolean |
useBasicAuth()
False for HTTPs, true for HTTP
|
public TakHttpClient(java.lang.String url)
url
- the base urlpublic TakHttpClient(java.lang.String url, java.lang.String connectString)
url
- the base urlconnectString
- the connectString which is in turn used for the certificate lookup to
ensure that https are made with the correct client cert for the portpublic TakHttpClient(java.lang.String baseUrl, org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory)
baseUrl
- the base urlsslSocketFactory
- the socket factory to be usedpublic TakHttpClient(java.lang.String baseUrl, org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory, int connectTimeout, int soTimeout)
baseUrl
- the base urlsslSocketFactory
- the socket factory to be usedconnectTimeout
- the connection timeoutsoTimeout
- the socket timeoutpublic static TakHttpClient GetHttpClient(java.lang.String url)
url
- the base urlpublic static TakHttpClient GetHttpClient(java.lang.String url, java.lang.String connectString)
url
- the base urlconnectString
- the connectString which is in turn used for the certificate lookup to
ensure that https are made with the correct client cert for the portpublic static TakHttpClient GetHttpClient(org.apache.http.conn.ssl.SSLSocketFactory factory, java.lang.String url)
factory
- the socket factory to useurl
- the url to use when creating a clientpublic java.lang.String getUrl()
public java.lang.String getUrl(java.lang.String path)
path
- the path to be used for lookuppublic boolean useBasicAuth()
public void addBasicAuthentication(HttpRequestBase request)
request
- the request to add basic auth to.public void addBasicAuthentication(HttpRequestBase request, AtakAuthenticationCredentials credentials)
request
- the request to add basic auth to.credentials
- the credentials to use to set up the basic auth.public java.lang.String get(java.lang.String url) throws java.io.IOException
url
- URL to getjava.io.IOException
public java.lang.String get(java.lang.String url, java.lang.String verify) throws java.io.IOException
url
- URL to getverify
- Verify response contains this stringjava.io.IOException
public java.lang.String get(java.lang.String url, java.lang.String verify, java.lang.String accept) throws java.io.IOException
java.io.IOException
public java.lang.String getGZip(java.lang.String url, java.lang.String verify) throws java.io.IOException
url
- the url to perform a http get on.verify
- the string that is to be contained in the responsejava.io.IOException
- when there is an issue with the gzip'd datapublic java.lang.String getGZip(java.lang.String url, java.lang.String verify, java.lang.String accept) throws java.io.IOException
url
- the url to perform a http get on.verify
- the string that is to be contained in the responseaccept
- Set "Accept" header on requestjava.io.IOException
- when there is an issue with the gzip'd datapublic java.lang.String get(java.lang.String url, java.lang.String verify, java.lang.String accept, java.lang.String acceptEncoding) throws java.io.IOException
url
- URL to getverify
- Verify response contains this stringaccept
- Set "Accept" header on requestjava.io.IOException
public boolean head(java.lang.String url) throws java.io.IOException
url
- url to perform a http head on.java.io.IOException
public TakHttpResponse execute(HttpRequestBase request) throws java.io.IOException
java.io.IOException
public TakHttpResponse execute(HttpRequestBase request, boolean bAddAuth) throws java.io.IOException
java.io.IOException
public TakHttpResponse execute(HttpRequestBase request, AtakAuthenticationCredentials credentials) throws java.io.IOException
java.io.IOException
public void shutdown()