code wiki / (root) / nx_https_fetch_file.nx

nx_https_fetch_file.nx

buildroot/runtime/nx_https_fetch_file.nx

4180 B97 linesdepth 21pulls 138 transitivereach 0 importersview sourcekind tooltopic https
docsdependenciesstructsconstsfunctions

about

nx_https_fetch_file.nx -- SOVEREIGN LARGE-ARTIFACT FETCH: stream an https response BODY straight to a file, in CONSTANT memory. Why this exists (2026-08-01). nx_https_get buffers the WHOLE response into one sys_mmap(HGC_OUTCAP) and then CORRECTLY refuses anything past it with NX_HTTPS_GC_BUF_OVERFLOW (surfaced to the CLI as code=8). That 4 MiB ceiling made every dataset, model weight, corpus and media artifact unreachable by sovereign fetch -- it is what blocked an 11MB standard CIF test sequence from media.xiph.org, and through that the whole ffmpeg-oracle BD-rate measurement (debt 1785634091). The fix is NOT to raise the constant. A per-fetch 256MB mmap is the memfloor incident waiting to happen (nx_skullsdf took 27.7GB and froze every seat's builds); raising a cap only moves the landmine. nx_https_get_stream ALREADY streams decrypted record plaintext to a dest_fd incrementally -- buffered append via gs_bufapp, Content-Length body_target, redirect following, Range support -- and it is gate-proven by nx_https_fetch_lib_gate and used in anger by the media vault. It was simply never exposed as a general CLI. So this WIRES THE PRIMITIVE THAT ALREADY EXISTS rather than building a second one. Usage: nx_https_fetch_file <url> <outpath> -> writes the response BODY (headers stripped, redirects followed by hf_fetch_to_file) to outpath. Prints: NX-HTTPS-FETCH-FILE url= out= status= bytes= verdict=OK|FAIL Exit: 0 ok / 2 usage-or-bad-url / 3 store-or-connect / 4 tls / 5 http / 6 cannot-open-outpath Deliberately NO connect-host:port override: that exists for our own domains and would mean copying hgc_parse_ipport verbatim (rule 15). Add it by EXTRACTING the shared parser if a caller ever needs it. license_tier: ORIGINAL

dependencies 13 imports · 0 importers

nx_syscalls.nx nx_csprng.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_tls13_client_validate_certifica nx_tls13_client_session_run.nx nx_tls13_chrome_session.nx nx_https_url_for_fetch.nx nx_https_url_connect.nx nx_https_get_complete.nx nx_https_fetch_file.nx

diagram shows first 10 each side; +3 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_csprng.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_tls13_client_validate_certificate.nxnx_tls13_client_session_run.nxnx_tls13_chrome_session.nxnx_https_url_for_fetch.nxnx_https_url_connect.nxnx_https_get_complete.nxnx_https_get_stream.nxnx_tls_cert_cache.nxnx_https_fetch_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main hff_put sys_write hff_slen hf_store_load nx_trust_store_load_from_c sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_nss_certdata_parse sys_mmap ↻ _pat_class_cert _pat_value_octal _pat_end _find_newline _starts_with _parse_octal_line sys_mmap ↻ _is_space _decode_octal_escape _is_octal trust_store_alloc sys_mmap ↻ nx_x509_trust_store_load sys_mmap ↻ x509_parse sys_mmap ↻ asn1_cursor_init asn1_expect_tag sys_mmap ↻ asn1_read_tlv_header asn1_read_length x509_read_tlv sys_mmap ↻ asn1_expect_tag ↻ x509_read_alg_id

structs

none

consts

39const HFF_MODE_0644: i64 = 420

functions

41func hff_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: hff_put
42func hff_put(s: *u8) -> i64 { sys_write(1, s, hff_slen(s)); return 0 }
called by 1: main calls 2: sys_writehff_slen
43func hff_putn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
57func main(argc: i64, argv: *i64) -> i64