A Range request from byte 0 is recorded only as fast as the browser reads
its range. If the browser stops early, as with a video that's never
played, the upstream request is aborted and nothing is captured. Add the
URL to the page's outlinks unless the recording succeeds.
Fetching a whole resource to answer a Range request for its middle, as when
a video is seeked, could delay the browser. Forward such requests without
recording them and add the URL to the page's outlinks instead, so the
frontier captures the whole resource.
Subresource requests are forwarded with the browser's Range header, so a
206 response is recorded as if it was the whole resource. Fetch without
Range and If-Range instead, and send the browser the range it asked for.
Captures are keyed by URL key and time, so a second capture of a URL in the same millisecond
replaces the first. Add the WARC file and offset to the key to keep them apart.
Error pages show only a generic message for the status code, so the reason a resource gives
in a ResourceException never reaches the user. Show it when it differs from the code's
default, and title 404 pages "Not found" since they aren't always for a missing page.
The class javadoc, which the bean reference shows, describes the index
in implementation terms. Describe what it does for a job instead, and
list it with the core beans.
The only way to see what's in a job's CaptureIndex is to read the BDB
database. Serve its captures as CDX lines at /engine/job/{job}/cdx,
with url taking an exact URL, a prefix ending in * or a domain starting
with *., for testing the index.
The index only looks up the latest capture of a single URL. Add a
query for all captures whose URL key equals or starts with a given key,
returned in batches so that no cursor stays open between them.
A Capture has no URL of its own: the index keys it by the SURT of the
canonical URL, which can't be turned back into the URL that was
fetched. Store the URL, return the URL key with each capture, and drop
parameters such as charset from the stored MIME type.
When a GET subresource was captured within replayMaxAgeSeconds, serve it
from the WARC file instead of fetching it again, so that pages sharing
resources don't refetch them once the browser has evicted them from its
cache or the page loads in another browser. Redirects back to the same
canonical URL aren't replayed as they would loop. Part of #831.
Revisits take the body from the record they refer to. Files are tried
under both their closed and .open names, as a file may be closed between
lookup and read.
Keys captures by the CrawlURI's canonical string and fetch time, newest
first, so later lookups find the latest capture of a resource the same
way the frontier identifies it. Revisits store the location of the
record they refer to. Part of #831.
What a server returns for missing URLs can change during a crawl, for
example once it has set a session cookie. When a page has the same
content as another recent page from the server and doesn't match any
probe, probe the server again, up to maxProbes probes in all (default
2). Pages matching any probe fingerprint are treated as soft 404s.
Move the soft 404 fields and methods from CrawlServer into
Soft404Detector.State, which CrawlServer holds and creates when first
requested. This keeps the detector's logic in one place and leaves
servers the detector never looks at without the state.
An app shell served for every path links to e.g. assets/css/app.css.
Fetched at /assets/css/app.css, that link looked like an echo of the
page's own URL and was removed before fingerprinting, so the page no
longer matched the probe, which got the same shell with the link
intact. That missed the first level of a relative-link trap.
Also compare the content without echoes removed.
Limiting probes to servers reached as seeds or by navlinks missed
soft 404 traps that grow through embeds and redirects. For example, an
in-scope host that serves its app shell for unknown paths: the shell's
relative embed links resolve one directory deeper each time, and every
response is the shell again.
Probe any server that returns an HTML page instead. Servers that only
serve non-HTML content, such as image CDNs, still aren't probed.
On GitHub's runners the first non-loopback address can be that of an
idle Docker bridge, and Docker's NAT rule rewrites the source of a
request from it to another address, which the proxy then refuses.
By default the Grid picks Chrome or Firefox, whichever it has a free
slot for, which on a node that detects every browser on its machine
could be either.
A browser that can't reach the proxy, through a firewall, a wrong
proxyHost or an allowlist missing its address, would otherwise count as
up and fail every page. As the last step of a launch, load an https page
through the proxy with a page ID, which the proxy answers itself, so that
CONNECT and its TLS interception are checked too. A browser that fails
to load it, or doesn't reach the proxy within 10 seconds, fails to
launch.
Selenium Grid ends a session after 300 seconds without traffic by
default, which is no longer than BrowserProcessor's default idle time
before closing a browser, so a page given to an idle browser could find
its session gone. BiDi commands count as traffic, so send a cheap one
every minute until the driver is closed.
http:// and https:// entries in browsers, or GridBrowser beans with
credentials, each create one session on a Grid. Grid nodes reach the
recording proxy at proxyHost, which defaults to loopback for a Grid
that shares this machine's loopback; otherwise the proxy needs to listen
off loopback and allow the nodes' addresses.
Remote browsers need the proxy to listen on an address they can reach.
It keeps listening on loopback too, for browsers on this machine.
Requests from addresses other than loopback and the allowed ones get
403, so opening the proxy to the network doesn't make it an open proxy.
Creates the session with POST {endpoint}/session and webSocketUrl: true,
connects to the reported WebSocket and deletes the session on close.
Selenium Grid reports its WebSocket URL with an internal address, such
as the container's IP and port, so only its path is kept and the scheme,
host and port come from the endpoint. Supports HTTP Basic authentication.
Waits up to ten minutes for the session, as Grid queues the request
while it has no free slot, but gives up when interrupted. Deleting the
session doesn't wait for the response, so stopping isn't held up by an
unreachable Grid.
A driver whose subclass doesn't end the connection by ending the
browser, such as one attached to a session on a remote endpoint, would
otherwise leave it open.
Separates the WebSocket, command and event handling from owning the
browser process, so that another subclass can attach to a session that
already exists.