Skip to content

Canonicalise hosts for politeness queues and the robots.txt cache - #2122

Open
abhinav-phi wants to merge 1 commit into
apache:mainfrom
abhinav-phi:issue-2082-host-canonicalisation
Open

Canonicalise hosts for politeness queues and the robots.txt cache#2122
abhinav-phi wants to merge 1 commit into
apache:mainfrom
abhinav-phi:issue-2082-host-canonicalisation

Conversation

@abhinav-phi

Copy link
Copy Markdown
Contributor

Fixes #2082.

okhttp percent-decodes and lowercases the host when it parses the URL, so http://exampl%65.org/ and http://example.org/ are one origin at connect time — but FetchItem.create, SimpleFetcherBolt.getPolitenessKey and HttpRobotRulesParser.getCacheKey keyed on the raw host string (only lowercased). Each spelling got its own politeness queue and its own robots.txt cache entry, so the per-host delay was applied several times in parallel to the same server (bounded by fetcher.threads.number, not by the number of aliases) and robots.txt was downloaded once per spelling.

Adds URLUtil.getCanonicalHost, which percent-decodes the host, strips a trailing dot and lowercases it, and uses it at all three call sites. This changes only how URLs are grouped, not which URLs are crawled.

…ache#2082)

okhttp percent-decodes and lowercases the host when it parses the URL,
but FetchItem.create, SimpleFetcherBolt.getPolitenessKey and
HttpRobotRulesParser.getCacheKey keyed on the raw host string, so
http://exampl%65.org/ and http://example.org/ were one origin at
connect time and two queue ids and two robots.txt cache entries in the
bolt. One server could end up with several delay clocks running in
parallel and its robots.txt fetched once per spelling.

URLUtil.getCanonicalHost percent-decodes the host, strips a trailing
dot and lowercases it, and all three call sites now use it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant