Class HttpBase
java.lang.Object
org.apache.nutch.protocol.http.api.HttpBase
- All Implemented Interfaces:
Configurable,Pluggable,Protocol
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe "Accept" request header value.protected StringThe "Accept-Charset" request header value.protected StringThe "Accept-Language" request header value.static final intstatic final Textprotected booleanControls whether or not to set Cookie HTTP header based on CrawlDatum metadataprotected booleanConfiguration directive for If-Modified-Since HTTP headerprotected intThe length limit for downloaded content, in bytes.protected longSkip page if Crawl-Delay longer than this value.protected intThe time limit to download the entire content, in seconds.protected booleanWhether to save partial fetches as truncated content.The proxy exception list.protected StringThe proxy hostname.protected intThe proxy port.protected Proxy.TypeThe proxy port.static final Textprotected booleanRecord response time in CrawlDatum's meta data, see property http.store.responsetime.protected booleanRecord the HTTP response header in the metadata, see propertystore.http.headers.protected booleanRecord the HTTP request in the metadata, see propertystore.http.request.protected booleanRecord the IP address of the responding server, see propertystore.ip.address.protected booleanRecord the HTTP and SSL/TLS protocol versions and the SSL/TLS cipher suites, see propertystore.protocol.versions.protected intThe network timeout in millisecondprotected booleanWhether to check TLS/SSL certificatesWhich TLS/SSL cipher suites to supportWhich TLS/SSL protocols to supportprotected booleanDo we use HTTP/1.1?protected booleanWhether to use HTTP/2protected booleanIndicates if a proxy is usedprotected StringThe Nutch 'User-Agent' request headerFields inherited from interface org.apache.nutch.protocol.Protocol
X_POINT_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionValue of "Accept-Language" request header sent by Nutch.getConf()If per-host cookies are configured, this method will look it up for the given url.intintThe time limit to download the entire content, in seconds.getProtocolOutput(Text url, CrawlDatum datum) Get theProtocolOutputfor a given url and crawldatumintprotected abstract ResponsegetResponse(URL url, CrawlDatum datum, boolean followRedirects) crawlercommons.robots.BaseRobotRulesgetRobotRules(URL url, CrawlDatum datum, List<Content> robotsTxtContent) Retrieve robot rules applicable for this URL.crawlercommons.robots.BaseRobotRulesgetRobotRules(Text url, CrawlDatum datum, List<Content> robotsTxtContent) Retrieve robot rules applicable for this URL.intbooleanbooleanbooleanprotected booleanisProxyException(String host) booleanbooleanbooleanbooleanWhether to save partial fetches as truncated content, cf.booleanprotected voidlogConf()protected static voidbyte[]processDeflateEncoded(byte[] compressed, URL url) byte[]processGzipEncoded(byte[] compressed, URL url) voidsetConf(Configuration conf) booleanbooleanbooleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.nutch.protocol.Protocol
resolveUrl
-
Field Details
-
RESPONSE_TIME
-
COOKIE
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
proxyHost
The proxy hostname. -
proxyPort
protected int proxyPortThe proxy port. -
proxyType
The proxy port. -
proxyException
The proxy exception list. -
useProxy
protected boolean useProxyIndicates if a proxy is used -
timeout
protected int timeoutThe network timeout in millisecond -
maxContent
protected int maxContentThe length limit for downloaded content, in bytes. -
maxDuration
protected int maxDurationThe time limit to download the entire content, in seconds. -
partialAsTruncated
protected boolean partialAsTruncatedWhether to save partial fetches as truncated content. -
userAgent
The Nutch 'User-Agent' request header -
acceptLanguage
The "Accept-Language" request header value. -
acceptCharset
The "Accept-Charset" request header value. -
accept
The "Accept" request header value. -
useHttp11
protected boolean useHttp11Do we use HTTP/1.1? -
useHttp2
protected boolean useHttp2Whether to use HTTP/2 -
responseTime
protected boolean responseTimeRecord response time in CrawlDatum's meta data, see property http.store.responsetime. -
storeIPAddress
protected boolean storeIPAddressRecord the IP address of the responding server, see propertystore.ip.address. -
storeHttpRequest
protected boolean storeHttpRequestRecord the HTTP request in the metadata, see propertystore.http.request. -
storeHttpHeaders
protected boolean storeHttpHeadersRecord the HTTP response header in the metadata, see propertystore.http.headers. -
storeProtocolVersions
protected boolean storeProtocolVersionsRecord the HTTP and SSL/TLS protocol versions and the SSL/TLS cipher suites, see propertystore.protocol.versions. -
maxCrawlDelay
protected long maxCrawlDelaySkip page if Crawl-Delay longer than this value. -
tlsCheckCertificate
protected boolean tlsCheckCertificateWhether to check TLS/SSL certificates -
tlsPreferredProtocols
Which TLS/SSL protocols to support -
tlsPreferredCipherSuites
Which TLS/SSL cipher suites to support -
enableIfModifiedsinceHeader
protected boolean enableIfModifiedsinceHeaderConfiguration directive for If-Modified-Since HTTP header -
enableCookieHeader
protected boolean enableCookieHeaderControls whether or not to set Cookie HTTP header based on CrawlDatum metadata
-
-
Constructor Details
-
HttpBase
public HttpBase()Creates a new instance of HttpBase -
HttpBase
public HttpBase(org.slf4j.Logger logger) Creates a new instance of HttpBase- Parameters:
logger- theLoggerto use in this HttpBase
-
-
Method Details
-
setConf
- Specified by:
setConfin interfaceConfigurable
-
getConf
- Specified by:
getConfin interfaceConfigurable
-
getProtocolOutput
Description copied from interface:ProtocolGet theProtocolOutputfor a given url and crawldatum- Specified by:
getProtocolOutputin interfaceProtocol- Parameters:
url- canonical urldatum- associatedCrawlDatum- Returns:
- the
ProtocolOutput
-
getProxyHost
-
getProxyPort
public int getProxyPort() -
useProxy
-
useProxy
-
useProxy
-
isProxyException
-
getTimeout
public int getTimeout() -
isIfModifiedSinceEnabled
public boolean isIfModifiedSinceEnabled() -
isCookieEnabled
public boolean isCookieEnabled() -
isStoreIPAddress
public boolean isStoreIPAddress() -
isStoreHttpRequest
public boolean isStoreHttpRequest() -
isStoreHttpHeaders
public boolean isStoreHttpHeaders() -
getMaxContent
public int getMaxContent() -
getMaxDuration
public int getMaxDuration()The time limit to download the entire content, in seconds. See the propertyhttp.time.limit.- Returns:
- the maximum duration
-
isStorePartialAsTruncated
public boolean isStorePartialAsTruncated()Whether to save partial fetches as truncated content, cf. the propertyhttp.partial.truncated.- Returns:
- true if partially fetched truncated content is stored
-
getUserAgent
-
getCookie
If per-host cookies are configured, this method will look it up for the given url.- Parameters:
url- the url to look-up a cookie for- Returns:
- the cookie or null
-
getAcceptLanguage
Value of "Accept-Language" request header sent by Nutch.- Returns:
- The value of the header "Accept-Language" header.
-
getAcceptCharset
-
getAccept
-
getUseHttp11
public boolean getUseHttp11() -
isTlsCheckCertificates
public boolean isTlsCheckCertificates() -
getTlsPreferredCipherSuites
-
getTlsPreferredProtocols
-
logConf
protected void logConf() -
processGzipEncoded
- Throws:
IOException
-
processDeflateEncoded
- Throws:
IOException
-
main
- Throws:
Exception
-
getResponse
protected abstract Response getResponse(URL url, CrawlDatum datum, boolean followRedirects) throws ProtocolException, IOException - Throws:
ProtocolExceptionIOException
-
getRobotRules
public crawlercommons.robots.BaseRobotRules getRobotRules(Text url, CrawlDatum datum, List<Content> robotsTxtContent) Description copied from interface:ProtocolRetrieve robot rules applicable for this URL.- Specified by:
getRobotRulesin interfaceProtocol- Parameters:
url- URL to checkdatum- page datumrobotsTxtContent- container to store responses when fetching the robots.txt file for debugging or archival purposes. Instead of a robots.txt file, it may include redirects or an error page (404, etc.). ResponseContentis appended to the passed list. If null is passed nothing is stored.- Returns:
- robot rules (specific for this URL or default), never null
-
getRobotRules
public crawlercommons.robots.BaseRobotRules getRobotRules(URL url, CrawlDatum datum, List<Content> robotsTxtContent) Description copied from interface:ProtocolRetrieve robot rules applicable for this URL.- Specified by:
getRobotRulesin interfaceProtocol- Parameters:
url- URL to checkdatum- page datumrobotsTxtContent- container to store responses when fetching the robots.txt file for debugging or archival purposes. Instead of a robots.txt file, it may include redirects or an error page (404, etc.). ResponseContentis appended to the passed list. If null is passed nothing is stored.- Returns:
- robot rules (specific for this URL or default), never null
-