Skip to main content

harness_webfetch/
constants.rs

1pub const DEFAULT_TIMEOUT_MS: u64 = 30_000;
2pub const MIN_TIMEOUT_MS: u64 = 1_000;
3pub const SESSION_BACKSTOP_MS: u64 = 120_000;
4
5pub const DEFAULT_MAX_REDIRECTS: u32 = 5;
6pub const MAX_MAX_REDIRECTS: u32 = 10;
7
8pub const INLINE_MARKDOWN_CAP: usize = 200 * 1024; // 200 KB
9pub const INLINE_RAW_CAP: usize = 2 * 1024 * 1024; // 2 MB
10pub const SPILL_HARD_CAP: usize = 10 * 1024 * 1024; // 10 MB
11pub const SPILL_HEAD_BYTES: usize = 100 * 1024;
12pub const SPILL_TAIL_BYTES: usize = 100 * 1024;
13
14pub const CACHE_TTL_MS: u64 = 5 * 60 * 1000;
15pub const MAX_URL_LENGTH: usize = 2 * 1024;
16
17/// Content-types that pass through as text. Anything else gets rejected
18/// with UNSUPPORTED_CONTENT_TYPE and a bash+curl hint.
19pub const TEXT_PASSTHROUGH_TYPES: &[&str] = &[
20    "text/plain",
21    "text/html",
22    "text/csv",
23    "text/markdown",
24    "text/xml",
25    "text/x-markdown",
26    "text/css",
27    "text/javascript",
28    "application/json",
29    "application/ld+json",
30    "application/xml",
31    "application/xhtml+xml",
32    "application/javascript",
33    "application/x-javascript",
34    "application/rss+xml",
35    "application/atom+xml",
36    "application/vnd.api+json",
37];
38
39pub const HTML_EXTRACTABLE_TYPES: &[&str] = &["text/html", "application/xhtml+xml"];
40
41/// Headers the tool manages; user-supplied copies are silently dropped.
42pub const MANAGED_HEADERS: &[&str] = &[
43    "host",
44    "content-length",
45    "transfer-encoding",
46    "connection",
47    "upgrade",
48];
49
50pub const DEFAULT_USER_AGENT: &str = "agent-sh-harness-webfetch/0.1.0";