Class HttpClientFetcherConfig
java.lang.Object
com.norconex.crawler.core.fetch.BaseFetcherConfig
com.norconex.crawler.web.fetch.impl.httpclient.HttpClientFetcherConfig
Generic HTTP Fetcher configuration.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanAuthentication configuration for sites requiring it.Gets the timeout when requesting a connection.The connection timeout for a connection to be established.Cookie specification to use when fetching documents.Optional prefix prepended to captured HTTP response fields.Gets the list of HTTP methods to be accepted by this fetcher.The local address, which may be useful when working with multiple network interfaces.Sets the period of time after which to evict idle connections from the connection pool.Sets the period of time a connection must be inactive to be checked in case it became stalled.intThe maximum number of connections that can be created.intThe maximum number of connections that can be used per route.intThe maximum number of redirects to be followed.Gets HTTP status codes to be considered as "Not found" state.The redirect URL provider.getRequestHeader(String name) Gets the HTTP request header value matching the given name, previously set withsetRequestHeader(String, String).Gets all HTTP request header names for headers previously set withsetRequestHeader(String, String).Headers to send with every HTTP request.Gets the maximum period of inactivity between two consecutive data packets.Gets the supported SSL/TLS protocols.The user-agent used when identifying the crawler to targeted web sites.Sets valid HTTP response status codes.inthashCode()booleanWhether adding "ETag"If-None-MatchHTTP request header is disabled.booleanWhether 'Expect: 100-continue' handshake is enabled.booleanWhether character encoding is detected instead of relying on the charset sometimes found in theContent-TypeHTTP response header.booleanWhether content type is detected instead of relying on returnedContent-TypeHTTP response header.booleanGets whether the forcing of non secure URLs to secure ones is disabled, according to the URL domainStrict-Transport-Securitypolicy (obtained from HTTP response header).booleanWhether adding theIf-Modified-SinceHTTP request header is disabled.booleanSets whether Server Name Indication (SNI) is disabled.booleanSets whether to trust all SSL certificate (affects only "https" connections).removeRequestHeader(String name) Remove the request header matching the given name.setAuthentication(HttpAuthConfig authentication) Authentication configuration for sites requiring it.setConnectionRequestTimeout(Duration connectionRequestTimeout) Gets the timeout when requesting a connection.setConnectionTimeout(Duration connectionTimeout) The connection timeout for a connection to be established.setCookieSpec(HttpClientFetcherConfig.CookieSpec cookieSpec) Cookie specification to use when fetching documents.setETagDisabled(boolean eTagDisabled) Whether adding "ETag"If-None-MatchHTTP request header is disabled.setExpectContinueEnabled(boolean expectContinueEnabled) Whether 'Expect: 100-continue' handshake is enabled.setForceCharsetDetection(boolean forceCharsetDetection) Whether character encoding is detected instead of relying on the charset sometimes found in theContent-TypeHTTP response header.setForceContentTypeDetection(boolean forceContentTypeDetection) Whether content type is detected instead of relying on returnedContent-TypeHTTP response header.setHeadersPrefix(String headersPrefix) Optional prefix prepended to captured HTTP response fields.setHstsDisabled(boolean hstsDisabled) Gets whether the forcing of non secure URLs to secure ones is disabled, according to the URL domainStrict-Transport-Securitypolicy (obtained from HTTP response header).setHttpMethods(List<HttpMethod> httpMethods) Sets the list of HTTP methods to be accepted by this fetcher.setIfModifiedSinceDisabled(boolean ifModifiedSinceDisabled) Whether adding theIf-Modified-SinceHTTP request header is disabled.setLocalAddress(String localAddress) The local address, which may be useful when working with multiple network interfaces.setMaxConnectionIdleTime(Duration maxConnectionIdleTime) Sets the period of time after which to evict idle connections from the connection pool.setMaxConnectionInactiveTime(Duration maxConnectionInactiveTime) Sets the period of time a connection must be inactive to be checked in case it became stalled.setMaxConnections(int maxConnections) The maximum number of connections that can be created.setMaxConnectionsPerRoute(int maxConnectionsPerRoute) The maximum number of connections that can be used per route.setMaxRedirects(int maxRedirects) The maximum number of redirects to be followed.final HttpClientFetcherConfigsetNotFoundStatusCodes(List<Integer> notFoundStatusCodes) Sets HTTP status codes to be considered as "Not found" state.setProxySettings(ProxySettings proxy) setRedirectUrlProvider(RedirectUrlProvider redirectUrlProvider) The redirect URL provider.setRequestHeader(String name, String value) Sets a default HTTP request header every HTTP connection should have.setRequestHeaders(Map<String, String> headers) Sets a default HTTP request headers every HTTP connection should have.setSniDisabled(boolean sniDisabled) Sets whether Server Name Indication (SNI) is disabled.setSocketTimeout(Duration socketTimeout) Gets the maximum period of inactivity between two consecutive data packets.setSslProtocols(List<String> sslProtocols) Sets the supported SSL/TLS protocols, such as SSLv3, TLSv1, TLSv1.1, and TLSv1.2.setTrustAllSSLCertificates(boolean trustAllSSLCertificates) Sets whether to trust all SSL certificate (affects only "https" connections).setUserAgent(String userAgent) The user-agent used when identifying the crawler to targeted web sites.setValidStatusCodes(List<Integer> validStatusCodes) Gets valid HTTP response status codes.toString()Methods inherited from class com.norconex.crawler.core.fetch.BaseFetcherConfig
getReferenceFilters, setReferenceFilters
-
Field Details
-
DEFAULT_TIMEOUT
-
DEFAULT_MAX_REDIRECT
public static final int DEFAULT_MAX_REDIRECT- See Also:
-
DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONS- See Also:
-
DEFAULT_MAX_CONNECTIONS_PER_ROUTE
public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE- See Also:
-
DEFAULT_MAX_IDLE_TIME
-
DEFAULT_VALID_STATUS_CODES
-
DEFAULT_NOT_FOUND_STATUS_CODES
-
-
Constructor Details
-
HttpClientFetcherConfig
public HttpClientFetcherConfig()
-
-
Method Details
-
getValidStatusCodes
Sets valid HTTP response status codes.- Returns:
- valid status codes
-
setValidStatusCodes
Gets valid HTTP response status codes.- Parameters:
validStatusCodes- valid status codes- Returns:
- this
-
getNotFoundStatusCodes
Gets HTTP status codes to be considered as "Not found" state. Default is 404.- Returns:
- "Not found" codes
-
setNotFoundStatusCodes
Sets HTTP status codes to be considered as "Not found" state.- Parameters:
notFoundStatusCodes- "Not found" codes- Returns:
- this
-
setRequestHeader
Sets a default HTTP request header every HTTP connection should have. Those are in addition to any default request headers Apache HttpClient may already provide.- Parameters:
name- HTTP request header namevalue- HTTP request header value- Returns:
- this
-
setRequestHeaders
Sets a default HTTP request headers every HTTP connection should have. Those are in addition to any default request headers Apache HttpClient may already provide.- Parameters:
headers- map of header names and values- Returns:
- this
-
getRequestHeader
Gets the HTTP request header value matching the given name, previously set withsetRequestHeader(String, String).- Parameters:
name- HTTP request header name- Returns:
- HTTP request header value or
nullif no match is found
-
getRequestHeaderNames
Gets all HTTP request header names for headers previously set withsetRequestHeader(String, String). If no request headers are set, it returns an empty array.- Returns:
- HTTP request header names
-
removeRequestHeader
Remove the request header matching the given name.- Parameters:
name- name of HTTP request header to remove- Returns:
- the previous value associated with the name, or
nullif there was no request header for the name.
-
getProxySettings
-
setProxySettings
-
getSslProtocols
Gets the supported SSL/TLS protocols. Default isnull, which means it will use those provided/configured by your Java platform.- Returns:
- SSL/TLS protocols
-
setSslProtocols
Sets the supported SSL/TLS protocols, such as SSLv3, TLSv1, TLSv1.1, and TLSv1.2. Note that specifying a protocol not supported by your underlying Java platform will not work.- Parameters:
sslProtocols- SSL/TLS protocols supported- Returns:
- this
-
getHttpMethods
Gets the list of HTTP methods to be accepted by this fetcher. Defaults areHttpMethod.GETandHttpMethod.HEAD.- Returns:
- HTTP methods
-
setHttpMethods
Sets the list of HTTP methods to be accepted by this fetcher. Defaults areHttpMethod.GETandHttpMethod.HEAD.- Parameters:
httpMethods- HTTP methods- Returns:
- this
-
getHeadersPrefix
Optional prefix prepended to captured HTTP response fields. Anullvalue (default) won't add any prefix. -
isForceContentTypeDetection
public boolean isForceContentTypeDetection()Whether content type is detected instead of relying on returnedContent-TypeHTTP response header. -
isForceCharsetDetection
public boolean isForceCharsetDetection()Whether character encoding is detected instead of relying on the charset sometimes found in theContent-TypeHTTP response header. -
getAuthentication
Authentication configuration for sites requiring it. Default isnull. -
getCookieSpec
Cookie specification to use when fetching documents. Default is relaxed. -
getConnectionTimeout
The connection timeout for a connection to be established. Default isDEFAULT_TIMEOUT. -
getSocketTimeout
Gets the maximum period of inactivity between two consecutive data packets. Default isDEFAULT_TIMEOUT. -
getConnectionRequestTimeout
Gets the timeout when requesting a connection. Default isDEFAULT_TIMEOUT. -
getLocalAddress
The local address, which may be useful when working with multiple network interfaces. -
isExpectContinueEnabled
public boolean isExpectContinueEnabled()Whether 'Expect: 100-continue' handshake is enabled. SeeRequestConfig.isExpectContinueEnabled() -
getMaxRedirects
public int getMaxRedirects()The maximum number of redirects to be followed. This can help prevent infinite loops. A value of zero effectively disables redirects. Default isDEFAULT_MAX_REDIRECT. -
getMaxConnections
public int getMaxConnections()The maximum number of connections that can be created. Typically, you would have at least the same amount as threads. Default isDEFAULT_MAX_CONNECTIONS. -
getMaxConnectionsPerRoute
public int getMaxConnectionsPerRoute()The maximum number of connections that can be used per route. Default isDEFAULT_MAX_CONNECTIONS_PER_ROUTE. -
getMaxConnectionIdleTime
Sets the period of time after which to evict idle connections from the connection pool. Default isDEFAULT_MAX_IDLE_TIME. -
getMaxConnectionInactiveTime
Sets the period of time a connection must be inactive to be checked in case it became stalled. Default is 0 (not pro-actively checked). -
getRequestHeaders
Headers to send with every HTTP request. -
isIfModifiedSinceDisabled
public boolean isIfModifiedSinceDisabled()Whether adding theIf-Modified-SinceHTTP request header is disabled. Servers supporting this header will only return the requested document if it was last modified since the supplied date. -
isETagDisabled
public boolean isETagDisabled()Whether adding "ETag"If-None-MatchHTTP 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. -
getUserAgent
The user-agent used when identifying the crawler to targeted web sites. It is highly recommended to always identify yourself. -
getRedirectUrlProvider
The redirect URL provider. Defaults toGenericRedirectUrlProvider. -
isTrustAllSSLCertificates
public boolean isTrustAllSSLCertificates()Sets whether to trust all SSL certificate (affects only "https" connections). This is typically a bad idea if you care to avoid "man-in-the-middle" attacks. Try to install a SSL certificate locally to ensure a proper certificate exchange instead.- Since:
- 1.3.0
-
isSniDisabled
public boolean isSniDisabled()Sets whether Server Name Indication (SNI) is disabled. -
isHstsDisabled
public boolean isHstsDisabled()Gets whether the forcing of non secure URLs to secure ones is disabled, according to the URL domainStrict-Transport-Securitypolicy (obtained from HTTP response header). -
setHeadersPrefix
Optional prefix prepended to captured HTTP response fields. Anullvalue (default) won't add any prefix.- Returns:
this.
-
setForceContentTypeDetection
Whether content type is detected instead of relying on returnedContent-TypeHTTP response header.- Returns:
this.
-
setForceCharsetDetection
Whether character encoding is detected instead of relying on the charset sometimes found in theContent-TypeHTTP response header.- Returns:
this.
-
setAuthentication
Authentication configuration for sites requiring it. Default isnull.- Returns:
this.
-
setCookieSpec
Cookie specification to use when fetching documents. Default is relaxed.- Returns:
this.
-
setConnectionTimeout
The connection timeout for a connection to be established. Default isDEFAULT_TIMEOUT.- Returns:
this.
-
setSocketTimeout
Gets the maximum period of inactivity between two consecutive data packets. Default isDEFAULT_TIMEOUT.- Returns:
this.
-
setConnectionRequestTimeout
Gets the timeout when requesting a connection. Default isDEFAULT_TIMEOUT.- Returns:
this.
-
setLocalAddress
The local address, which may be useful when working with multiple network interfaces.- Returns:
this.
-
setExpectContinueEnabled
Whether 'Expect: 100-continue' handshake is enabled. SeeRequestConfig.isExpectContinueEnabled()- Returns:
this.
-
setMaxRedirects
The maximum number of redirects to be followed. This can help prevent infinite loops. A value of zero effectively disables redirects. Default isDEFAULT_MAX_REDIRECT.- Returns:
this.
-
setMaxConnections
The maximum number of connections that can be created. Typically, you would have at least the same amount as threads. Default isDEFAULT_MAX_CONNECTIONS.- Returns:
this.
-
setMaxConnectionsPerRoute
The maximum number of connections that can be used per route. Default isDEFAULT_MAX_CONNECTIONS_PER_ROUTE.- Returns:
this.
-
setMaxConnectionIdleTime
Sets the period of time after which to evict idle connections from the connection pool. Default isDEFAULT_MAX_IDLE_TIME.- Returns:
this.
-
setMaxConnectionInactiveTime
Sets the period of time a connection must be inactive to be checked in case it became stalled. Default is 0 (not pro-actively checked).- Returns:
this.
-
setIfModifiedSinceDisabled
Whether adding theIf-Modified-SinceHTTP request header is disabled. Servers supporting this header will only return the requested document if it was last modified since the supplied date.- Returns:
this.
-
setETagDisabled
Whether adding "ETag"If-None-MatchHTTP 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.- Returns:
this.
-
setUserAgent
The user-agent used when identifying the crawler to targeted web sites. It is highly recommended to always identify yourself.- Returns:
this.
-
setRedirectUrlProvider
The redirect URL provider. Defaults toGenericRedirectUrlProvider.- Returns:
this.
-
setTrustAllSSLCertificates
Sets whether to trust all SSL certificate (affects only "https" connections). This is typically a bad idea if you care to avoid "man-in-the-middle" attacks. Try to install a SSL certificate locally to ensure a proper certificate exchange instead.- Returns:
this.- Since:
- 1.3.0
-
setSniDisabled
Sets whether Server Name Indication (SNI) is disabled.- Returns:
this.
-
setHstsDisabled
Gets whether the forcing of non secure URLs to secure ones is disabled, according to the URL domainStrict-Transport-Securitypolicy (obtained from HTTP response header).- Returns:
this.
-
equals
- Overrides:
equalsin classBaseFetcherConfig
-
canEqual
- Overrides:
canEqualin classBaseFetcherConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseFetcherConfig
-
toString
- Overrides:
toStringin classBaseFetcherConfig
-