code wiki / (root) / nx_https_fetch_lib.nx

nx_https_fetch_lib.nx

buildroot/runtime/nx_https_fetch_lib.nx

34757 B783 linesdepth 20pulls 149 transitivereach 24 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 19 imports · 15 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_http_resolve_redirect.nx nx_https_fetch_lib.nx nx_browser_page_demo_test.nx nx_edge_vantage.nx nx_fetch_status_live_gate_t252.nx nx_funcheck.nx nx_gen_http_verify.nx nx_http_client_gate.nx nx_http_dechunk_boundary_gate.nx nx_https_fetch_file.nx nx_https_fetch_lib_gate.nx nx_https_get_cli.nx

diagram shows first 10 each side; +9 more imports, +5 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_http_resolve_redirect.nxnx_redirect_resolve.nxnx_https_url_connect.nxnx_https_get_complete.nxnx_https_get_stream.nxnx_tls_cert_cache.nxnx_tls12_client_session.nxnx_http_response_parse.nxnx_gzip_wrap.nxnx_zlib_wrap.nx

imported by: nx_browser_page_demo_test.nxnx_edge_vantage.nxnx_fetch_status_live_gate_t252.nxnx_funcheck.nxnx_gen_http_verify.nxnx_http_client_gate.nxnx_http_dechunk_boundary_gate.nxnx_https_fetch_file.nxnx_https_fetch_lib_gate.nxnx_https_get_cli.nxnx_https_post_lib.nxnx_mvault.nxnx_mvault_fetch.nxnx_publish_verify.nxnx_vault_capture.nx

structs

none

consts

41const HF_MAGIC_2047: i64 = 2047
42const HF_MAGIC_2048: i64 = 2048
43const HF_T12_PT_CAP: i64 = 20000
44const HF_T12_MAX_RECORDS: i64 = 4096
46const HF_CERTDATA: *u8 = "data/mozilla_certdata.txt\x00"
47const HF_STORE_CAP: i64 = 4194304
51const HF_ERR_STORE: i64 = 0 - 2
52const HF_ERR_URL: i64 = 0 - 3
53const HF_ERR_CONNECT: i64 = 0 - 4
54const HF_ERR_TLS: i64 = 0 - 5
55const HF_ERR_HTTP: i64 = 0 - 6
56const HF_ERR_HEADERS: i64 = 0 - 7
57const HF_ERR_HEADER_REDIRECT: i64 = 0 - 8
62const HF_DEC_IDENTITY: i64 = 0 - 30 // nothing to strip: caller keeps the original bytes verbatim
63const HF_DEC_ECODING: i64 = 0 - 31 // br/zstd/stacked: we cannot decode it, so we REFUSE rather than emit wrong bytes
64const HF_DEC_CHUNK: i64 = 0 - 32 // malformed chunked framing -- refuse a partial document
65const HF_DEC_INFLATE: i64 = 0 - 33 // invalid or unsupported compressed stream
66const HF_DEC_CAPACITY: i64 = 0 - 34 // caller-owned decoded output budget exhausted

functions

69func hf_store_load() -> i64
90func hf_open(store_i: i64, url: *u8, cip: i64, cport: i64, box: *i64) -> i64
201func hf_fetch_to_file_once(store_i: i64, url: *u8, cip: i64, cport: i64, loc: *u8,
235func hf_fetch12_headers_once(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64, xhdr: *u8, xhdr_len: i64) -> i64
337func hf_fetch12_once(store_i: i64,url: *u8,cip: i64,cport: i64,out: *u8,cap: i64) -> i64
called by 1: main calls 1: hf_fetch12_headers_once
346func hf_fetch_headers_once(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64, xhdr: *u8, xhdr_len: i64) -> i64
359func hf_fetch_once(store_i: i64,url: *u8,cip: i64,cport: i64,out: *u8,cap: i64) -> i64
366func hf_location(resp: *u8, n: i64, out: *u8, cap: i64) -> i64
416func hf_fetch_mode_headers(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64, decode: i64, xhdr: *u8, xhdr_len: i64) -> i64
467func hf_fetch_mode(store_i: i64,url: *u8,cip: i64,cport: i64,out: *u8,cap: i64,decode: i64) -> i64
473func hf_fetch(store_i: i64, url: *u8, cip: i64, cport: i64, out: *u8, cap: i64) -> i64
495func hf_fetch_to_file(store_i: i64, url: *u8, cip: i64, cport: i64,
528func hf_body_off(resp: *u8, n: i64) -> i64
538func hf_status(resp: *u8, n: i64) -> i64
581func hfd_streq(a: *u8, b: *u8) -> i64
called by 1: hfd_hdr_enc
588func hfd_hexval(c: i64) -> i64
597func hfd_hdr_chunked(b: *u8, he: i64) -> i64
618func hfd_hdr_enc(b: *u8, he: i64) -> i64
671func hfd_dechunk(src: *u8, n: i64, out: *u8, cap: i64) -> i64
676func hfd_rename_hdr(b: *u8, he: i64, pat: *u8, rep: *u8, plen: i64) -> i64
called by 1: hf_decode_transport
705func hf_decode_transport(resp: *u8, n: i64, out: *u8, cap: i64) -> i64
754func hf_header_block_valid(p: *u8,n: i64) -> i64
770func hf_header_redirect_same_origin(a: *u8,b: *u8) -> i64