nx_https_fetch_lib.nx
buildroot/runtime/nx_https_fetch_lib.nx
about
nx_https_fetch_lib.nx -- the sovereign HTTPS GET composition, as a LIBRARY.
WHY THIS EXISTS (2026-07-31): the whole working fetch path -- trust-store load,
CSPRNG, url parse, connect (with optional override), TLS 1.3 chrome-JA3
handshake, cert cache, path+query assembly, HTTP GET -- lived inside
nx_https_get_cli.nx's main(). Any second consumer (the album downloader) had
exactly two bad options: duplicate ~90 lines of crypto setup, or shell out.
Rule 15: a pattern needed by more than one consumer belongs in a lib, and
duplicated crypto setup is the kind that diverges SILENTLY -- one copy gets the
cert-cache fix or the recv_hs reassembly fix and the other quietly does not.
The logic here is LIFTED VERBATIM from the proven CLI, only parameterised. The
CLI is then re-pointed at this lib so there is ONE implementation, and its
behaviour is re-verified live after the move (a refactor of a crown-jewel path
is not done until the old entry point is proven still working).
★ THE STORE IS LOADED SEPARATELY ON PURPOSE. nx_trust_store_load_from_certdata
parses a ~4 MiB Mozilla bundle. Doing that per file would make a 300-file album
pay it 300 times. hf_store_load() once, then hf_fetch() per url.
license_tier: ORIGINAL
dependencies 14 imports · 5 importers
diagram shows first 10 each side; +4 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_connect.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_tls12_client_session.nx
imported by: nx_https_fetch_file.nxnx_https_fetch_lib_gate.nxnx_https_get_cli.nxnx_mvault.nxnx_mvault_fetch.nx
structs
| none |
consts
| 36 | const HF_MAGIC_2047: i64 = 2047 |
| 37 | const HF_MAGIC_2048: i64 = 2048 |
| 38 | const HF_T12_PT_CAP: i64 = 20000 |
| 39 | const HF_T12_MAX_RECORDS: i64 = 4096 |
| 41 | const HF_CERTDATA: *u8 = "data/mozilla_certdata.txt\x00" |
| 42 | const HF_STORE_CAP: i64 = 4194304 |
| 46 | const HF_ERR_STORE: i64 = 0 - 2 |
| 47 | const HF_ERR_URL: i64 = 0 - 3 |
| 48 | const HF_ERR_CONNECT: i64 = 0 - 4 |
| 49 | const HF_ERR_TLS: i64 = 0 - 5 |
| 50 | const HF_ERR_HTTP: i64 = 0 - 6 |
functions
| 53 | func hf_store_load() -> i64 |
| 74 | func hf_open(store_i: i64, url: *u8, cip: i64, cport: i64, box: *i64) -> i64 |
| 152 | func hf_fetch_to_file_once(store_i: i64, url: *u8, cip: i64, cport: i64, loc: *u8, |
| 186 | func hf_fetch12_once(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64) -> i64 |
| 291 | func hf_fetch_once(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64) -> i64 |
| 307 | func hf_location(resp: *u8, n: i64, out: *u8, cap: i64) -> i64 called by 1: hf_fetch |
| 353 | func hf_fetch(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64) -> i64 |
| 402 | func hf_fetch_to_file(store_i: i64, url: *u8, cip: i64, cport: i64, |
| 435 | func hf_body_off(resp: *u8, n: i64) -> i64 called by 1: mvf_fetch_album_pfx |
| 445 | func hf_status(resp: *u8, n: i64) -> i64 called by 1: hf_fetch |