code wiki / (root) / nx_range_header.nx

nx_range_header.nx

buildroot/runtime/nx_range_header.nx

6601 B198 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic range
docsdependenciesstructsconstsfunctions

about

range_header.nx -- parse HTTP Range request header. RFC 7233 ยง3.1. Range requests let a client ask for a byte range of a resource instead of the whole thing. Essential for: - Video / audio seeking (HTML5 <video> sends Range requests when you click the scrubber) - Resumable downloads (browsers retry interrupted downloads with \"Range: bytes=<last-byte-received>-\") - Large-file diff tools Format (most useful forms): Range: bytes=0-499 <- first 500 bytes Range: bytes=500- <- byte 500 to end Range: bytes=-500 <- last 500 bytes Range: bytes=0-499,1000-1499 <- multiple ranges (multipart) We only support bytes= unit; other units (chars=, seconds= in some video specs) are non-standard and rare. Invariants: RH1 Returns RangeSpec array with (start, end) resolved vs the file size. "-500" -> (size-500, size-1). "500-" -> (500, size-1). RH2 Ranges that extend past the file are clamped. RH3 Empty / unparseable input returns RH_ERR_FORMAT so caller falls back to serving 200 with full body.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_range_header.nx

imports: nx_syscalls.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 range_parse sys_mmap ↻ rh_parse_uint rh_is_digit

structs

41struct RangeSpec

consts

35const RH_MAGIC_7233: i64 = 7233
37const RH_ERR_FORMAT: i64 = -1
38const RH_ERR_UNIT: i64 = -2
39const RH_ERR_OVERFLOW: i64 = -3

functions

47func rh_is_digit(b: i64) -> i64
called by 1: rh_parse_uint
55func rh_parse_uint(buf: *u8, off: *i64, end: i64) -> i64
called by 1: range_parse calls 1: rh_is_digit
70func range_parse(buf: *u8, n: i64, total_size: i64,
called by 1: main calls 2: sys_mmaprh_parse_uint
164func main() -> i64