code wiki / (root) / nx_http_fetch.nx

nx_http_fetch.nx

buildroot/runtime/nx_http_fetch.nx

8569 B132 linesdepth 6pulls 8 transitivereach 0 importersview sourcekind tooltopic http
docsdependenciesstructsconstsfunctions

about

nx_http_fetch.nx -- EAT THE DEBT: a plaintext HTTP (port 80, no TLS) fetch so HTTP-ONLY hosts are reachable. images.cocodataset.org is an S3 static-website endpoint (HTTP-only) -> the TLS-only fetcher fails at handshake (-3). This wires the SHIPPED pieces: nx_dns_a_resolve (host->IPv4, copied self-contained) + nx_http_client_get (socket+GET+drain) + a minimal status/redirect parse. Follows http:// redirects (a redirect to https:// is reported -- that host wants TLS, use the https fetcher). File-driven (data/mp_img_url.txt -> data/mp_img_dest.txt). license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_http_client.nx nx_http_fetch.nx

imports: nx_syscalls.nxnx_http_client.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap rdcfg sys_openat_rd sys_read sys_close w sys_write sys_exit hf_parse_url wn w ↻ sys_mmap ↻ sys_write ↻ nx_dns_a_resolve sys_socket sys_set_socket_timeout sys_mmap ↻ sys_setsockopt sys_munmap sys_mmap ↻ da_sockaddr da_build_query da_qname sys_sendto sys_close ↻ sys_recvfrom da_parse da_u16 da_skip_name nx_http_client_sockaddr_ip nx_http_client_get sys_socket ↻ nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_close ↻ sys_mmap ↻

structs

none

consts

9const K_MAGIC_4660: i64 = 4660
10const K_MAGIC_2048: i64 = 2048
11const K_MAGIC_4096: i64 = 4096
12const K_MAGIC_1024: i64 = 1024
13const K_MAGIC_16777216: i64 = 16777216

functions

15func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: wnmain calls 1: sys_write
16func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
called by 1: main calls 3: wsys_mmapsys_write
17func shx(v: i64) -> i64 { let b: *u8=sys_mmap(4); var i: i64=0; while i<2 { let n: i64=(v>>((1-i)*4))&0xF; if n<10{b[i]=(48+n) as u8} else {b[i]=(87+n) as u8} i=i+1 } sys_write(1,b,2); return 0 }
18func rdcfg(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0{return 0-1} var n: i64=sys_read(fd,buf,cap-1); sys_close(fd); if n<0{return 0-1} var go: i64=1; while go==1{go=0; if n>0{ let c: i64=buf[n-1] as i64; if c==10{n=n-1;go=1} if c==13{n=n-1;go=1} if c==32{n=n-1;go=1} }} buf[n]=0 as u8; return n }
called by 1: main calls 3: sys_openat_rdsys_readsys_close
21func da_u16(buf: *u8, o: i64) -> i64 { return ((buf[o] as i64) << 8) | (buf[o+1] as i64) }
called by 1: da_parse
22func da_qname(host: *u8, out: *u8, off: i64) -> i64
called by 1: da_build_query
33func da_build_query(host: *u8, qid: i64, out: *u8) -> i64
called by 1: nx_dns_a_resolve calls 1: da_qname
38func da_skip_name(buf: *u8, off: i64, n: i64) -> i64 { var o: i64=off; while o<n { let b: i64=buf[o] as i64; if b==0{return o+1} if (b&0xc0)==0xc0{return o+2} o=o+1+b } return o }
called by 1: da_parse
39func da_parse(buf: *u8, n: i64, out_ip: *u8) -> i64
called by 1: nx_dns_a_resolve calls 2: da_u16da_skip_name
47func da_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64
called by 1: nx_dns_a_resolve
51func nx_dns_a_resolve(host: *u8, out_ip: *u8) -> i64
62func hf_find(buf: *u8, n: i64, from: i64, needle: *u8) -> i64
called by 1: main
68func hf_parse_url(url: *u8, hbuf: *u8, pbuf: *u8) -> i64
called by 1: main
84func main() -> i64