code wiki / (root) / nx_fetchprobec.nx

nx_fetchprobec.nx source

↩ module page · 40 lines · 1829 B

1// nx_fetchprobec.nx -- BISECT: does importing nx_lib_search + store + openalex break the fetch path? 2// nx_feedfetch fetches https://phzmapi.org/97202.json fine on the SAME lib, while nx_libdata 3// returns -2 NX_FF_CONNECT on the identical URL from its FIRST iteration. Only difference is the 4// import closure. expect_exit: 0 license_tier: ORIGINAL 5import "nx_syscalls.nx" 6import "nx_x509_trust_store.nx" 7import "nx_trust_store_load_from_certdata.nx" 8import "nx_https_fetch_follow.nx" 9import "nx_store_seed_lib.nx" 10import "nx_lib_openalex.nx" 11import "nx_lib_search.nx" 12const K_MAGIC_4194304: i64 = 4194304 13const K_MAGIC_16777216: i64 = 16777216 14func fp_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 15func fp_puts(s: *u8) -> i64 { sys_write(1, s, fp_len(s)); return 0 } 16func fp_putn(v: i64) -> i64 { 17 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 18 var m: i64 = v 19 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 20 let d: *u8 = sys_mmap(24) 21 var k: i64 = 0 22 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 23 var j: i64 = k - 1 24 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 25 return 0 26} 27func main() -> i64 { 28 let tr: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 29 if tr <= 0 { fp_puts("certdata FAIL\n" as *u8); return 1 } 30 let store: *TrustStore = tr as *TrustStore 31 let out: *u8 = sys_mmap(K_MAGIC_16777216) 32 let st: *i64 = sys_mmap(8) as *i64 33 let n: i64 = nx_https_fetch_follow_best("https://phzmapi.org/97202.json" as *u8, store, out, K_MAGIC_16777216, 6, st) 34 fp_puts("PROBEc bytes=" as *u8) 35 fp_putn(n) 36 fp_puts(" status=" as *u8) 37 fp_putn(st[0]) 38 fp_puts("\n" as *u8) 39 return 0 40}