code wiki / (root) / nx_fetch_unit.nx

nx_fetch_unit.nx

buildroot/runtime/nx_fetch_unit.nx

6535 B177 linesdepth 21pulls 129 transitivereach 6 importersview sourcekind librarytopic fetch
docsdependenciesstructsconstsfunctions

about

nx_fetch_unit.nx -- the SHARED staged-fetch unit (Rule #15: this logic lived copy-pasted in _dlr_fetch_one + _ed_fetch_html; extracted 2026-06-10 in the standards audit so the next consumer inherits fixes instead of forking them). module: nishi-core.search.fetch_unit depends: nx_https_get.nx stack capability: CORE_COMPUTE nx_fetch_staged(url, bodybuf, cap): validated-HTTPS GET with 301/302/303/307/308 Location follow (https-only, hop-capped FU_HOPS) and Transfer-Encoding chunked DECODE. Returns decoded body length into bodybuf, or 0/negative on failure. Callers decide what the body becomes (html->text, raw html, header probe...).

dependencies 6 imports · 6 importers

nx_str.nx nx_syscalls.nx nx_csprng.nx nx_x509_trust_store.nx nx_pem_loader.nx nx_https_get.nx nx_fetch_unit.nx _dlr_fetch_one.nx _ed_fetch_html.nx nx_apm_sweep.nx nx_clock_sitecheck.nx nx_sched_research_fetch.nx nx_url_get.nx

imports: nx_str.nxnx_syscalls.nxnx_csprng.nxnx_x509_trust_store.nxnx_pem_loader.nxnx_https_get.nx

imported by: _dlr_fetch_one.nx_ed_fetch_html.nxnx_apm_sweep.nxnx_clock_sitecheck.nxnx_sched_research_fetch.nxnx_url_get.nx

structs

none

consts

21const FU_MAGIC_2048: i64 = 2048
23const FU_CAP: i64 = 524288
24const FU_HOPS: i64 = 3 // 1 fetch + up to 2 redirect follows (anti-loop)

functions

26func fu_body_off(resp: *u8, n: i64) -> i64
called by 1: nx_fetch_staged
31func fu_lc(c: i64) -> i64 { if c >= 0x41 { if c <= 0x5A { return c + 0x20 } } return c }
32func fu_find_ci(resp: *u8, lim: i64, needle: *u8) -> i64
47func fu_status(resp: *u8, n: i64) -> i64
called by 1: nx_fetch_staged
59func fu_location(resp: *u8, hdr_lim: i64, cururl: *u8, loc: *u8, cap: i64) -> i64
called by 1: nx_fetch_staged calls 1: fu_find_ci
89func fu_dechunk(resp: *u8, bo: i64, n: i64, out: *u8, cap: i64) -> i64
127func nx_fetch_staged(url: *u8, bodybuf: *u8, cap: i64) -> i64