code wiki / (root) / nx_http_resolve_redirect.nx

nx_http_resolve_redirect.nx

buildroot/runtime/nx_http_resolve_redirect.nx

5645 B132 linesdepth 3pulls 4 transitivereach 3 importersview sourcekind librarytopic http
docsdependenciesstructsconstsfunctions

about

nx_http_resolve_redirect.nx -- client-side 3xx redirect Location follow. Given a raw HTTP response (status line + headers block, possibly trailing body) and the URL we fetched it from, this primitive: 1. detects whether the status is a follow-worthy 3xx (301/302/303/307/308 per RFC 7231 §6.4) 2. extracts the Location header value case-insensitively 3. resolves Location against the base URL (RFC 3986 §5.2) so both absolute Location and relative Location work 4. writes the resolved absolute URL to a caller-supplied buffer Composes: - nx_http_header_find (RFC 7230 §3.2.4 case-insensitive) - nx_url_resolve (RFC 3986 §5.2) Out of scope (the orchestrator that loops nx_https_get + this primitive is `nx_https_get_following` in a follow-up arc): - looping with hop limit - cookie + auth header carry-forward across hops - method preservation (301 vs 307 vs 308 semantics) -- caller decides via the returned `permanent` + `method_preserving` verdict bits nx_safety_envelope: intended_use: "HTTP redirect follow for the bits-up browser." sil_target: SIL1 evidence: [rfc7231_section_6_4_canonical_basis, composes_url_resolver, scheme_allowlist_caller_responsibility] hazard_register: [bug-tape-open-redirect-to-evil-site, bug-tape-redirect-to-javascript-url, bug-tape-redirect-loop-uncapped] residual_risk: "Caller MUST cap redirect count + audit scheme of resolved URL (substrate emits the resolved URL verbatim)." verdict: NOT_YET_EVALUATED

dependencies 3 imports · 3 importers

nx_syscalls.nx nx_http_header_find.nx nx_url_resolve.nx nx_http_resolve_redirect.nx nx_cms_redirect_exceed_gate.nx nx_cms_redirect_gate.nx nx_navigation_test.nx

imports: nx_syscalls.nxnx_http_header_find.nxnx_url_resolve.nx

imported by: nx_cms_redirect_exceed_gate.nxnx_cms_redirect_gate.nxnx_navigation_test.nx

structs

none

consts

44const NX_REDIRECT_RESOLVED: i64 = 0 // out buffer holds an absolute URL
45const NX_REDIRECT_NOT_3XX: i64 = 1 // status is not a follow-worthy 3xx
46const NX_REDIRECT_NO_LOCATION: i64 = 2 // 3xx but no Location header
47const NX_REDIRECT_BAD_LOCATION: i64 = 3 // Location contained CR/LF/NUL
48const NX_REDIRECT_BAD_BASE: i64 = 4 // base URL had no scheme
49const NX_REDIRECT_TRUNC: i64 = 5 // out buffer too small

functions

54func nx_redirect_status_is_followable(status: i64) -> i64
65func nx_redirect_status_is_permanent(status: i64) -> i64
called by 1: main
73func nx_redirect_status_preserves_method(status: i64) -> i64
called by 1: main
81func _redirect_location_is_safe(loc: *u8, loc_n: i64) -> i64
106func nx_http_resolve_redirect(