public static class APIHttpClient.Builder extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
accept
Types of encodings that are acceptable
|
protected String |
acceptLanguage
Accepted languages
|
static String |
DEFAULT_ACCEPT
Default accept header value
|
static String |
DEFAULT_ACCEPT_LANGUAGE
Default accept language header value
|
static boolean |
DEFAULT_ALLOW_GZIP
Default allow gzip flag
|
static boolean |
DEFAULT_ALLOW_UNTRUSTED_SSL
Default allow untrusted ssl flag
|
static long |
DEFAULT_CRAWL_DELAY
Default delay between requests
|
static long |
DEFAULT_READ_TIMEOUT
Default socket read timeout
|
static String |
DEFAULT_USER_AGENT
Default user agent
|
protected long |
readTimeout
The socket read timeout
|
protected String |
userAgent
The user agent string to use
|
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
APIHttpClient |
build()
Build the HttpClient shared instance.
|
APIHttpClient.Builder |
setAccept(String accept)
Set the accept request header value
|
APIHttpClient.Builder |
setAcceptLanguages(String accept)
Set the value for the Accept-Language request header
|
APIHttpClient.Builder |
setAllowgzip(boolean on)
Set accept gzip header.
|
APIHttpClient.Builder |
setAllowUntrustedSSL(boolean allow)
Set the allow untrusted ssl flag
|
APIHttpClient.Builder |
setCrawlDelay(long delay)
Sets the crawl delay in milliseconds.
|
APIHttpClient.Builder |
setHost(String host)
Set the host
|
APIHttpClient.Builder |
setReadTimeout(long timeout)
Sets the socket read timeout in milliseconds
|
APIHttpClient.Builder |
setUserAgent(String ua)
Set the user agent string to use
|
public static final String DEFAULT_USER_AGENT
public static final long DEFAULT_READ_TIMEOUT
public static final String DEFAULT_ACCEPT
public static final String DEFAULT_ACCEPT_LANGUAGE
public static final boolean DEFAULT_ALLOW_GZIP
public static final boolean DEFAULT_ALLOW_UNTRUSTED_SSL
public static final long DEFAULT_CRAWL_DELAY
protected String userAgent
protected long readTimeout
protected String accept
protected String acceptLanguage
public APIHttpClient.Builder setUserAgent(String ua)
ua
- User agent stringpublic APIHttpClient.Builder setReadTimeout(long timeout)
timeout
- millisecondspublic APIHttpClient.Builder setAccept(String accept)
accept
- Accept header valuepublic APIHttpClient.Builder setAcceptLanguages(String accept)
accept
- valuepublic APIHttpClient.Builder setAllowgzip(boolean on)
on
- togglepublic APIHttpClient.Builder setCrawlDelay(long delay) throws IllegalArgumentException
delay
- Delay between requestsIllegalArgumentException
- if delay is less than zeropublic APIHttpClient.Builder setAllowUntrustedSSL(boolean allow)
allow
- enabledpublic APIHttpClient.Builder setHost(String host)
host
- hostpublic APIHttpClient build() throws APIException, URISyntaxException
URISyntaxException
- if URIBuilder throws an exception
with the hostAPIException
- If there is a problem building the HttpClientCopyright © 2017. All rights reserved.