code wiki / (root) / nx_https_fetch_lib.nx

nx_https_fetch_lib.nx

buildroot/runtime/nx_https_fetch_lib.nx

19855 B462 linesdepth 20pulls 137 transitivereach 6 importersview sourcekind librarytopic https
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_connect.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_fetch_lib.nx nx_https_fetch_file.nx nx_https_fetch_lib_gate.nx nx_https_get_cli.nx nx_mvault.nx nx_mvault_fetch.nx

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

36const HF_MAGIC_2047: i64 = 2047
37const HF_MAGIC_2048: i64 = 2048
38const HF_T12_PT_CAP: i64 = 20000
39const HF_T12_MAX_RECORDS: i64 = 4096
41const HF_CERTDATA: *u8 = "data/mozilla_certdata.txt\x00"
42const HF_STORE_CAP: i64 = 4194304
46const HF_ERR_STORE: i64 = 0 - 2
47const HF_ERR_URL: i64 = 0 - 3
48const HF_ERR_CONNECT: i64 = 0 - 4
49const HF_ERR_TLS: i64 = 0 - 5
50const HF_ERR_HTTP: i64 = 0 - 6

functions

53func hf_store_load() -> i64
74func hf_open(store_i: i64, url: *u8, cip: i64, cport: i64, box: *i64) -> i64
152func hf_fetch_to_file_once(store_i: i64, url: *u8, cip: i64, cport: i64, loc: *u8,
186func hf_fetch12_once(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64) -> i64
291func hf_fetch_once(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64) -> i64
307func hf_location(resp: *u8, n: i64, out: *u8, cap: i64) -> i64
called by 1: hf_fetch
353func hf_fetch(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64) -> i64
402func hf_fetch_to_file(store_i: i64, url: *u8, cip: i64, cport: i64,
435func hf_body_off(resp: *u8, n: i64) -> i64
called by 1: mvf_fetch_album_pfx
445func hf_status(resp: *u8, n: i64) -> i64
called by 1: hf_fetch