Make Content-Location header url INFERRED not REFFER hop type since Content-Location is not for redirection (#151)

This commit is contained in:
Hunter
2016-04-13 15:19:21 -07:00
committed by Noah Levitt
parent 124907341f
commit a02a32cdfe
@@ -62,8 +62,7 @@ public class ExtractorHTTP extends Extractor {
protected void extract(CrawlURI curi) {
// discover headers if present
addHeaderLink(curi, "Location");
addHeaderLink(curi, "Content-Location");
addContentLocationHeaderLink(curi, "Content-Location");
addRefreshHeaderLink(curi, "Refresh");
// try /favicon.ico for every HTTP(S) URI
@@ -92,6 +91,19 @@ public class ExtractorHTTP extends Extractor {
}
}
protected void addContentLocationHeaderLink(CrawlURI curi, String headerKey) {
String headerValue = curi.getHttpResponseHeader(headerKey);
if (headerValue != null) {
try {
UURI dest = UURIFactory.getInstance(curi.getUURI(), headerValue);
addOutlink(curi, dest.toString(), LinkContext.INFERRED_MISC, Hop.INFERRED);
numberOfLinksExtracted.incrementAndGet();
} catch (URIException e) {
logUriError(e, curi.getUURI(), headerValue);
}
}
}
protected void addHeaderLink(CrawlURI curi, String headerName, String url) {
try {
UURI dest = UURIFactory.getInstance(curi.getUURI(), url);