nx_route_test.nx source
↩ module page · 34 lines · 1633 B
1// nx_route_test.nx -- probe several routes on the live edge to tell whether the
2// new binary broke routing GLOBALLY (everything -> home page => ROLLBACK) or only
3// /research is not matching (targeted fix). Prints Content-Length + <title> per path.
4import "nx_syscalls.nx"
5import "nx_lib_fetch.nx"
6
7func rt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
8func rt_wr(p: *u8, n: i64) -> i64 { sys_write(1, p, n); return 0 }
9func rt_putn(v: i64) -> i64 {
10 let bb: *u8 = sys_mmap(28); var m: i64 = v
11 if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) }
12 let t: *u8 = sys_mmap(28); var k: i64 = 0
13 if m == 0 { t[0] = 48 as u8; k = 1 }
14 while m > 0 { t[k] = (48 + (m - (m/10)*10)) as u8; m = m / 10; k = k + 1 }
15 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0
16}
17func rt_get(store: *TrustStore, url: *u8) -> i64 {
18 let cap: i64 = 131072
19 let buf: *u8 = sys_mmap(cap)
20 rt_puts("--- GET "); rt_puts(url); rt_puts("\n")
21 let gc: i64 = nx_lib_fetch(store, url, buf, cap)
22 rt_puts(" bytes="); rt_putn(gc); rt_puts(" head: ")
23 if gc > 0 { var w: i64 = gc; if w > 90 { w = 90 } rt_wr(buf, w) }
24 rt_puts("\n")
25 return 0
26}
27func main() -> i64 {
28 let store: *TrustStore = nx_lib_fetch_store()
29 if store == 0 as *TrustStore { rt_puts("no CA store\n"); return 1 }
30 rt_get(store, "https://nishifamily.com:8443/\x00" as *u8)
31 rt_get(store, "https://nishifamily.com:8443/wiki\x00" as *u8)
32 rt_get(store, "https://nishifamily.com:8443/research/work/GBIF_1000003\x00" as *u8)
33 return 0
34}