public class GenericHttpFetcherConfig extends Object implements IXMLConfigurable
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_CONNECTIONS |
static int |
DEFAULT_MAX_CONNECTIONS_PER_ROUTE |
static int |
DEFAULT_MAX_IDLE_TIME |
static int |
DEFAULT_MAX_REDIRECT |
static List<Integer> |
DEFAULT_NOT_FOUND_STATUS_CODES |
static int |
DEFAULT_TIMEOUT |
static List<Integer> |
DEFAULT_VALID_STATUS_CODES |
Constructor and Description |
---|
GenericHttpFetcherConfig() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
HttpAuthConfig |
getAuthConfig() |
Charset |
getConnectionCharset()
Gets the connection character set.
|
int |
getConnectionRequestTimeout()
Gets the timeout when requesting a connection, in milliseconds
|
int |
getConnectionTimeout()
Gets the connection timeout until a connection is established,
in milliseconds.
|
String |
getCookieSpec() |
String |
getHeadersPrefix() |
List<HttpMethod> |
getHttpMethods()
Gets the list of HTTP methods to be accepted by this fetcher.
|
String |
getLocalAddress()
Gets the local address (IP or hostname).
|
int |
getMaxConnectionIdleTime()
Gets the period of time in milliseconds after which to evict idle
connections from the connection pool.
|
int |
getMaxConnectionInactiveTime()
Gets the period of time in milliseconds a connection must be inactive
to be checked in case it became stalled.
|
int |
getMaxConnections()
Gets the maximum number of connections that can be created.
|
int |
getMaxConnectionsPerRoute()
Gets the maximum number of connections that can be used per route.
|
int |
getMaxRedirects()
Gets the maximum number of redirects to be followed.
|
List<Integer> |
getNotFoundStatusCodes()
Gets HTTP status codes to be considered as "Not found" state.
|
ProxySettings |
getProxySettings() |
IRedirectURLProvider |
getRedirectURLProvider()
Gets the redirect URL provider.
|
String |
getRequestHeader(String name)
Gets the HTTP request header value matching the given name, previously
set with
setRequestHeader(String, String) . |
List<String> |
getRequestHeaderNames()
Gets all HTTP request header names for headers previously set
with
setRequestHeader(String, String) . |
int |
getSocketTimeout()
Gets the maximum period of inactivity between two consecutive data
packets, in milliseconds.
|
List<String> |
getSSLProtocols()
Gets the supported SSL/TLS protocols.
|
String |
getUserAgent() |
List<Integer> |
getValidStatusCodes() |
int |
hashCode() |
boolean |
isDisableETag()
Gets whether adding "ETag"
If-None-Match
HTTP request header is disabled. |
boolean |
isDisableHSTS()
Gets whether the forcing of non secure URLs to secure ones is disabled,
according to the URL domain
Strict-Transport-Security policy
(obtained from HTTP response header). |
boolean |
isDisableIfModifiedSince()
Gets whether adding the
If-Modified-Since HTTP request
header is disabled. |
boolean |
isDisableSNI()
Gets whether Server Name Indication (SNI) is disabled.
|
boolean |
isExpectContinueEnabled()
Whether 'Expect: 100-continue' handshake is enabled.
|
boolean |
isForceCharsetDetection()
Gets whether character encoding is detected instead of relying on
HTTP response header.
|
boolean |
isForceContentTypeDetection()
Gets whether content type is detected instead of relying on
HTTP response header.
|
boolean |
isTrustAllSSLCertificates()
Whether to trust all SSL certificates (affects only "https" connections).
|
void |
loadFromXML(XML xml) |
String |
removeRequestHeader(String name)
Remove the request header matching the given name.
|
void |
saveToXML(XML xml) |
void |
setAuthConfig(HttpAuthConfig authConfig) |
void |
setConnectionCharset(Charset connectionCharset)
Sets the connection character set.
|
void |
setConnectionRequestTimeout(int connectionRequestTimeout)
Sets the timeout when requesting a connection, in milliseconds.
|
void |
setConnectionTimeout(int connectionTimeout)
Sets the connection timeout until a connection is established,
in milliseconds.
|
void |
setCookieSpec(String cookieSpec) |
void |
setDisableETag(boolean disableETag)
Sets whether whether adding "ETag"
If-None-Match
HTTP request header is disabled. |
void |
setDisableHSTS(boolean disableHSTS)
Sets whether the forcing of non secure URLs to secure ones is disabled,
according to the URL domain
Strict-Transport-Security policy
(obtained from HTTP response header). |
void |
setDisableIfModifiedSince(boolean disableIfModifiedSince)
Sets whether adding the
If-Modified-Since HTTP request
header is disabled. |
void |
setDisableSNI(boolean disableSNI)
Sets whether Server Name Indication (SNI) is disabled.
|
void |
setExpectContinueEnabled(boolean expectContinueEnabled)
Sets whether 'Expect: 100-continue' handshake is enabled.
|
void |
setForceCharsetDetection(boolean forceCharsetDetection)
Sets whether character encoding is detected instead of relying on
HTTP response header.
|
void |
setForceContentTypeDetection(boolean forceContentTypeDetection)
Sets whether content type is detected instead of relying on
HTTP response header.
|
void |
setHeadersPrefix(String headersPrefix) |
void |
setHttpMethods(List<HttpMethod> httpMethods)
Sets the list of HTTP methods to be accepted by this fetcher.
|
void |
setLocalAddress(String localAddress)
Sets the local address, which may be useful when working with multiple
network interfaces.
|
void |
setMaxConnectionIdleTime(int maxConnectionIdleTime)
Sets the period of time in milliseconds after which to evict idle
connections from the connection pool.
|
void |
setMaxConnectionInactiveTime(int maxConnectionInactiveTime)
Sets the period of time in milliseconds a connection must be inactive
to be checked in case it became stalled.
|
void |
setMaxConnections(int maxConnections)
Sets maximum number of connections that can be created.
|
void |
setMaxConnectionsPerRoute(int maxConnectionsPerRoute)
Sets the maximum number of connections that can be used per route.
|
void |
setMaxRedirects(int maxRedirects)
Sets the maximum number of redirects to be followed.
|
void |
setNotFoundStatusCodes(int... notFoundStatusCodes)
Sets HTTP status codes to be considered as "Not found" state.
|
void |
setNotFoundStatusCodes(List<Integer> notFoundStatusCodes)
Sets HTTP status codes to be considered as "Not found" state.
|
void |
setProxySettings(ProxySettings proxy) |
void |
setRedirectURLProvider(IRedirectURLProvider redirectURLProvider)
Sets the redirect URL provider
|
void |
setRequestHeader(String name,
String value)
Sets a default HTTP request header every HTTP connection should have.
|
void |
setRequestHeaders(Map<String,String> headers)
Sets a default HTTP request headers every HTTP connection should have.
|
void |
setSocketTimeout(int socketTimeout)
Sets the maximum period of inactivity between two consecutive data
packets, in milliseconds.
|
void |
setSSLProtocols(List<String> sslProtocols)
Sets the supported SSL/TLS protocols, such as SSLv3, TLSv1, TLSv1.1,
and TLSv1.2.
|
void |
setTrustAllSSLCertificates(boolean trustAllSSLCertificates)
Sets whether to trust all SSL certificate.
|
void |
setUserAgent(String userAgent) |
void |
setValidStatusCodes(int... validStatusCodes)
Gets valid HTTP response status codes.
|
void |
setValidStatusCodes(List<Integer> validStatusCodes)
Gets valid HTTP response status codes.
|
String |
toString() |
public static final int DEFAULT_TIMEOUT
public static final int DEFAULT_MAX_REDIRECT
public static final int DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE
public static final int DEFAULT_MAX_IDLE_TIME
public IRedirectURLProvider getRedirectURLProvider()
public void setRedirectURLProvider(IRedirectURLProvider redirectURLProvider)
redirectURLProvider
- redirect URL providerpublic void setValidStatusCodes(List<Integer> validStatusCodes)
validStatusCodes
- valid status codespublic void setValidStatusCodes(int... validStatusCodes)
validStatusCodes
- valid status codespublic List<Integer> getNotFoundStatusCodes()
public final void setNotFoundStatusCodes(int... notFoundStatusCodes)
notFoundStatusCodes
- "Not found" codespublic final void setNotFoundStatusCodes(List<Integer> notFoundStatusCodes)
notFoundStatusCodes
- "Not found" codespublic String getHeadersPrefix()
public void setHeadersPrefix(String headersPrefix)
public boolean isForceContentTypeDetection()
true
to enable detectionpublic void setForceContentTypeDetection(boolean forceContentTypeDetection)
forceContentTypeDetection
- true
to enable detectionpublic boolean isForceCharsetDetection()
true
to enable detectionpublic void setForceCharsetDetection(boolean forceCharsetDetection)
forceCharsetDetection
- true
to enable detectionpublic String getUserAgent()
public void setUserAgent(String userAgent)
public void setRequestHeader(String name, String value)
name
- HTTP request header namevalue
- HTTP request header valuepublic void setRequestHeaders(Map<String,String> headers)
headers
- map of header names and valuespublic String getRequestHeader(String name)
setRequestHeader(String, String)
.name
- HTTP request header namenull
if
no match is foundpublic List<String> getRequestHeaderNames()
setRequestHeader(String, String)
. If no request headers
are set, it returns an empty array.public String removeRequestHeader(String name)
name
- name of HTTP request header to removenull
if there was no request header for the name.public String getCookieSpec()
CookieSpecs
public void setCookieSpec(String cookieSpec)
cookieSpec
- the cookieSpec to use as defined in CookieSpecs
public ProxySettings getProxySettings()
public void setProxySettings(ProxySettings proxy)
public int getConnectionTimeout()
public void setConnectionTimeout(int connectionTimeout)
DEFAULT_TIMEOUT
.connectionTimeout
- connection timeoutpublic int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
DEFAULT_TIMEOUT
.socketTimeout
- socket timeoutpublic int getConnectionRequestTimeout()
public void setConnectionRequestTimeout(int connectionRequestTimeout)
DEFAULT_TIMEOUT
.connectionRequestTimeout
- connection request timeoutpublic Charset getConnectionCharset()
public void setConnectionCharset(Charset connectionCharset)
connectionCharset
- connection character setpublic boolean isExpectContinueEnabled()
true
if enabledpublic void setExpectContinueEnabled(boolean expectContinueEnabled)
RequestConfig.isExpectContinueEnabled()
expectContinueEnabled
- true
if enabledpublic int getMaxRedirects()
public void setMaxRedirects(int maxRedirects)
DEFAULT_MAX_REDIRECT
.maxRedirects
- maximum number of redirects to be followedpublic String getLocalAddress()
public void setLocalAddress(String localAddress)
localAddress
- locale addresspublic int getMaxConnections()
public void setMaxConnections(int maxConnections)
DEFAULT_MAX_CONNECTIONS
.maxConnections
- maximum number of connectionspublic int getMaxConnectionsPerRoute()
public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute)
DEFAULT_MAX_CONNECTIONS_PER_ROUTE
.maxConnectionsPerRoute
- maximum number of connections per routepublic int getMaxConnectionIdleTime()
public void setMaxConnectionIdleTime(int maxConnectionIdleTime)
DEFAULT_MAX_IDLE_TIME
.maxConnectionIdleTime
- amount of time after which to evict idle
connectionspublic int getMaxConnectionInactiveTime()
public void setMaxConnectionInactiveTime(int maxConnectionInactiveTime)
maxConnectionInactiveTime
- period of time in millisecondspublic boolean isTrustAllSSLCertificates()
true
if trusting all SSL certificatespublic void setTrustAllSSLCertificates(boolean trustAllSSLCertificates)
trustAllSSLCertificates
- true
if trusting all SSL
certificatespublic boolean isDisableSNI()
true
if disabledpublic void setDisableSNI(boolean disableSNI)
disableSNI
- true
if disabledpublic List<String> getSSLProtocols()
null
,
which means it will use those provided/configured by your Java
platform.public void setSSLProtocols(List<String> sslProtocols)
sslProtocols
- SSL/TLS protocols supportedpublic boolean isDisableIfModifiedSince()
If-Modified-Since
HTTP request
header is disabled.
Servers supporting this header will only return the requested document
if it was last modified since the supplied date.true
if disabledpublic void setDisableIfModifiedSince(boolean disableIfModifiedSince)
If-Modified-Since
HTTP request
header is disabled.
Servers supporting this header will only return the requested document
if it was last modified since the supplied date.disableIfModifiedSince
- true
if disabledpublic boolean isDisableETag()
If-None-Match
HTTP request header is disabled.
Servers supporting this header will only return the requested document
if the ETag value has changed, indicating a more recent version is
available.true
if disabledpublic void setDisableETag(boolean disableETag)
If-None-Match
HTTP request header is disabled.
Servers supporting this header will only return the requested document
if the ETag value has changed, indicating a more recent version is
available.disableETag
- true
if disabledpublic boolean isDisableHSTS()
Strict-Transport-Security
policy
(obtained from HTTP response header).true
if disabledpublic void setDisableHSTS(boolean disableHSTS)
Strict-Transport-Security
policy
(obtained from HTTP response header).disableHSTS
- true
if disabledpublic HttpAuthConfig getAuthConfig()
public void setAuthConfig(HttpAuthConfig authConfig)
public List<HttpMethod> getHttpMethods()
HttpMethod.GET
and HttpMethod.HEAD
.public void setHttpMethods(List<HttpMethod> httpMethods)
HttpMethod.GET
and HttpMethod.HEAD
.httpMethods
- HTTP methodspublic void loadFromXML(XML xml)
loadFromXML
in interface IXMLConfigurable
public void saveToXML(XML xml)
saveToXML
in interface IXMLConfigurable
Copyright © 2009–2023 Norconex Inc.. All rights reserved.