3200 Commits
Author SHA1 Message Date
Alex Osborne 60ef515f9a Merge pull request #835 from internetarchive/range-requests
BrowserProcessor: handle Range requests without recording partial responses
2026-11-27 22:03:39 +09:00
Alex Osborne cf543310c2 Merge pull request #836 from internetarchive/fix-disabled-console-links
Disable the Scripting Console and Browse Beans links when there's no application context
2026-11-27 21:58:43 +09:00
Alex Osborne e6ae67ddd1 Disable the Scripting Console and Browse Beans links when there's no application context
Addresses confusion encountered in #743.
2026-11-27 18:08:20 +09:00
Alex Osborne b670908ff9 MitmProxyTest: share one keystore between tests
Each test generates its own keystore, which takes about half a second.
2026-11-27 17:47:15 +09:00
Alex Osborne 4caa3a9826 BrowserProcessor: queue ranged subresources whose recording fails
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.
2026-11-27 17:47:15 +09:00
Alex Osborne 939d8514c4 BrowserProcessorTest: test Range requests from the browser 2026-11-27 17:47:15 +09:00
Alex Osborne 963ab13538 Document how browser Range requests are captured 2026-11-27 17:47:15 +09:00
Alex Osborne eb1ca03346 BrowserProcessor: queue subresources requested from a later byte
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.
2026-11-27 17:47:15 +09:00
Alex Osborne 3903d6799d BrowserProcessor: record whole subresources for Range requests
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.
2026-11-27 17:47:15 +09:00
Alex Osborne 363ec8ee3f BrowserProcessor: replay the requested range of a capture
Replay sends the whole capture in answer to a Range request. That's
valid, but media players then download all of it to seek.
2026-11-27 17:47:15 +09:00
Alex Osborne b6281796aa CapturedResponse: add the body's length when it's known 2026-11-27 17:47:15 +09:00
Alex Osborne 621a499f44 MitmProxy: add serveRequestedRange to send the client a range of the response
This lets the proxy fetch and record a whole resource while answering a
browser's Range request with the part it asked for.
2026-11-27 17:47:15 +09:00
Alex Osborne 4de01aaf7b BdbCaptureIndex: skip 206 Partial Content responses
A partial response replayed to a request without Range would give the
browser a truncated resource.
2026-11-27 17:47:15 +09:00
Alex Osborne 783de9d636 BdbCaptureIndex: keep captures made in the same millisecond
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.
2026-11-27 17:47:15 +09:00
Alex Osborne baf32a0fde Merge pull request #833 from internetarchive/capture-index
Replay browser subresources from a CaptureIndex of the crawl's WARC records
2026-11-27 17:32:30 +09:00
Alex Osborne beaa1b70e0 Document the CDX endpoint in the API guide 2026-11-26 18:25:20 +09:00
Alex Osborne 55f1dcc8b0 EngineStatusService: show the error's description
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.
2026-11-26 17:50:49 +09:00
Alex Osborne 5aa0831c3a Document replaying subresources from a CaptureIndex 2026-11-26 17:39:10 +09:00
Alex Osborne fdedeeb4ab Add BdbCaptureIndex to the bean reference
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.
2026-11-26 17:39:10 +09:00
Alex Osborne 5b168cadd4 Add a CDX endpoint for querying a job's CaptureIndex
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.
2026-11-26 17:39:10 +09:00
Alex Osborne d9999f804b CaptureIndex: add paged queries by URL key
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.
2026-11-26 17:39:10 +09:00
Alex Osborne bdaffcc077 BdbCaptureIndex: store each capture's URL
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.
2026-11-26 17:39:10 +09:00
Alex Osborne dbb779f899 Add a commented-out CaptureIndex to the default profiles
BrowserProcessor and the WARC writer pick up a CaptureIndex only if the
job declares one. Show how to declare it in both default profiles.
2026-11-26 17:39:10 +09:00
Alex Osborne 12a02b883b BrowserProcessor: replay subresources from a CaptureIndex
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.
2026-11-26 17:39:10 +09:00
Alex Osborne bbbd52f637 Read a capture's HTTP response back from its WARC file
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.
2026-11-26 17:39:10 +09:00
Alex Osborne 7bd9a676b6 MitmProxy: allow sending repeated response headers
Replaying a recorded response needs headers like Set-Cookie to keep all
their values.
2026-11-26 17:39:10 +09:00
Alex Osborne 6228b3096e Index written records when WARCWriter has a CaptureIndex
The test reads the indexed records back from the still-open WARC file,
since replay will need to do the same.
2026-11-26 17:39:10 +09:00
Alex Osborne 54f5daabe9 Add CaptureIndex of WARC records written during the crawl
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.
2026-11-26 17:39:10 +09:00
Alex Osborne b10e1302ad Bump webarchive-commons from 3.0.6 to 3.1.0
For the WARC path and record length recorded in WARCRecordInfo
(iipc/webarchive-commons#186), the HeaderedArchiveRecord read fix
(iipc/webarchive-commons#187) and the flushing of uncompressed records
after each write (iipc/webarchive-commons#188).
2026-11-26 17:32:00 +09:00
Alex Osborne f452526868 Add AGENTS.md 2026-11-26 16:18:27 +09:00
Alex Osborne f08fdb2cee Merge pull request #830 from internetarchive/soft404-probe-any-hop
Soft404Detector: probe more servers and catch soft 404s that appear mid-crawl
2026-11-26 15:59:55 +09:00
Alex Osborne 7b2279cba5 Soft404Detector: skip hashing when there's nothing to match or probe 2026-11-24 14:35:01 +09:00
Alex Osborne 4660d6ed7f Soft404Detector: re-probe when the same page repeats
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.
2026-11-24 14:02:17 +09:00
Alex Osborne f9363ca0ae Soft404Detector: keep per-server state in a State class
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.
2026-11-24 13:11:56 +09:00
Alex Osborne 2e80500747 Soft404Detector: match pages reached by their own relative links
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.
2026-11-24 13:02:26 +09:00
Alex Osborne c2341ba9e2 Soft404Detector: probe servers reached by any hop
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.
2026-11-24 12:42:28 +09:00
Alex Osborne 3ed49d29fb Merge pull request #829 from internetarchive/browser-grid
BrowserProcessor: Selenium Grid support
2026-11-23 21:05:00 +09:00
Alex Osborne 1f1460b3d5 MitmProxyTest: pick an address on an interface that's up
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.
2026-11-20 19:06:33 +09:00
Alex Osborne 5b99d7e426 docs: document opening browsers on a Selenium Grid 2026-11-20 18:42:15 +09:00
Alex Osborne 2fbf9d19fe GridBrowser: let browserName choose between Chrome, Firefox and Edge
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.
2026-11-20 18:42:15 +09:00
Alex Osborne 1fde99a24d BrowserProcessor: check that a launched browser can reach the recording proxy
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.
2026-11-20 18:42:15 +09:00
Alex Osborne 1993d05566 RemoteWebDriverBiDi: keep the session alive while it's open
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.
2026-11-20 18:42:15 +09:00
Alex Osborne 44ee73c301 BrowserProcessor: open browser sessions on a Selenium Grid
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.
2026-11-20 18:42:15 +09:00
Alex Osborne 8c34f4723a BrowserProcessor: separate launching a browser from setting up its session
So that a browser can come from somewhere other than a launch.
2026-11-20 18:42:15 +09:00
Alex Osborne 6ff26a0743 BrowserProcessor: make the proxy's address, port and allowed sources configurable 2026-11-20 18:42:15 +09:00
Alex Osborne 17c5dac361 BrowserProcessor: keep the Firefox prefs as a map and generate user.js from it
So they can also be sent as capabilities to browsers we don't launch.
2026-11-20 18:42:15 +09:00
Alex Osborne c009c92be2 MitmProxy: make the listen address configurable and allow only listed sources
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.
2026-11-20 18:42:15 +09:00
Alex Osborne 1f3896d316 RemoteWebDriverBiDi: attach to a session created over WebDriver HTTP
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.
2026-11-20 15:35:55 +09:00
Alex Osborne c8f06b8438 AbstractWebDriverBiDi: close the WebSocket on close
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.
2026-11-20 15:20:51 +09:00
Alex Osborne bc034c8eea LocalWebDriverBiDi: move the BiDi connection into AbstractWebDriverBiDi
Separates the WebSocket, command and event handling from owning the
browser process, so that another subclass can attach to a session that
already exists.
2026-11-20 15:19:58 +09:00