code wiki / (root) / nx_http_server.nx

nx_http_server.nx

buildroot/runtime/nx_http_server.nx

19036 B393 linesdepth 3pulls 3 transitivereach 82 importersview sourcekind librarytopic http
docsdependenciesstructsconstsfunctions

about

nx_http_server.nx -- bind/listen/accept-loop HTTP/1.1 server. Closes the F1 rank-4 ship-order (CWE-352 CSRF). Composes existing substrate primitives -- nothing new at the protocol layer: nx_http_io.nx -- nx_http_parse_request / nx_http_write_response nx_http_resp.nx -- response builder (status, headers, body) nx_http_router.nx -- route dispatch (method + path -> handler_id) nx_syscalls_x86_64 -- socket / bind / listen / accept / setsockopt This file is the COMPOSITION FILE: it ties the existing pieces into an accept-loop with sealed-enum verdicts at every step. Per audit-dashboard roadmap phase 2: this is the load-bearing surface that lets nishifamily.com/audit be served live. The dispatch handler for /audit reads docs/audit/snapshot.json + nx_html_render's output buffer; this server is the wrapper. Sealed-enum verdict (server-state, distinct from HTTP status codes): NXS_OK accept-loop iteration succeeded NXS_SOCKET_ERR socket() failed -- usually EACCES (port<1024) or EMFILE (too many open files) NXS_BIND_ERR bind() failed -- usually EADDRINUSE (port in use) NXS_LISTEN_ERR listen() failed NXS_ACCEPT_ERR accept() returned negative (usually EINTR; caller retries) NXS_PARSE_ERR request didn't parse as HTTP/1.1 NXS_WRITE_ERR write to client socket failed (client gone) NXS_BAD_ARG null pointer / negative size / unknown method Per cardinal user-owns-every-bit: caller picks the bind address + port; substrate doesn't auto-bind to 0.0.0.0:80. Default in the helper is 127.0.0.1 (loopback) -- user must explicitly opt in to public binding. Per cardinal feedback-no-third-party-trust-native-or-nothing: no external HTTP framework. No nginx, no caddy, no fastcgi. CSRF prevention (rank-4 CWE-352): the route-registration helper nx_http_server_register_state_change refuses any path that

dependencies 2 imports · 52 importers

nx_syscalls.nx nx_http_io.nx nx_http_server.nx nx_andelinwest_daemon.nx nx_archive_daemon.nx nx_audit_server_daemon.nx nx_audit_server_main.nx nx_audit_server_routed.nx nx_aw_devserver.nx nx_aw_mtls_proxy.nx nx_aw_tlsproxy.nx nx_browser_view_serve.nx nx_clean_serve_daemon.nx

diagram shows first 10 each side; +0 more imports, +42 more importers in the complete lists below.

imports: nx_syscalls.nxnx_http_io.nx

imported by: nx_andelinwest_daemon.nxnx_archive_daemon.nxnx_audit_server_daemon.nxnx_audit_server_main.nxnx_audit_server_routed.nxnx_aw_devserver.nxnx_aw_mtls_proxy.nxnx_aw_tlsproxy.nxnx_browser_view_serve.nxnx_clean_serve_daemon.nxnx_cleanwatch_serve.nxnx_cloexec_gate.nxnx_crawl_main.nxnx_dev_api_serve.nxnx_dist_serve.nxnx_edge_daemon.nxnx_fin_serve.nxnx_hotlisten_gate.nxnx_http_redirect_daemon.nxnx_http_server_test.nxnx_iot_hub_serve.nxnx_media_server.nxnx_media_sniff_daemon.nxnx_mock_web.nxnx_mtls_test_daemon.nxnx_pages_daemon.nxnx_pages_http_redirect.nxnx_pages_https_daemon.nxnx_search_crawl_server.nxnx_search_server.nxnx_serve_roadmap.nxnx_sigpipe_gate.nxnx_sitegen_studio_daemon.nxnx_sites_daemon.nxnx_sites_daemon_v2.nxnx_sites_sni_cert_gate.nxnx_sni_router.nxnx_sni_router_gate.nxnx_sovgit_git.nxnx_sovgit_serve.nxnx_status_daemon.nxnx_tls13_ed25519_test_daemon.nxnx_tools_api_serve.nxnx_torrent_daemon.nxnx_translate_daemon.nxnx_ui_serve.nxnx_vroom_daemon.nxnx_wiki_doc_handler.nxnx_wiki_https_daemon.nxnx_wiki_https_daemon_mv.nxnx_wiki_main.nxnx_wiki_routes.nx

structs

none

consts

68const NXS_MAGIC_65535: i64 = 65535
72const NXS_OK: i64 = 0
73const NXS_SOCKET_ERR: i64 = 1
74const NXS_BIND_ERR: i64 = 2
75const NXS_LISTEN_ERR: i64 = 3
76const NXS_ACCEPT_ERR: i64 = 4
77const NXS_PARSE_ERR: i64 = 5
78const NXS_WRITE_ERR: i64 = 6
79const NXS_BAD_ARG: i64 = 7
80const NXS_VERDICT_N: i64 = 8
159const AF_INET_CONST: i64 = 2
259const SO_REUSEPORT_CONST: i64 = 15

functions

82func nxs_verdict_is_valid(v: i64) -> i64
called by 1: main
88func nxs_verdict_name(v: i64) -> *u8
called by 2: mainmain
114func nx_http_server_make_sockaddr(out: *u8, port_host_order: i64,
140func nx_http_server_addr_loopback(out: *u8, port: i64) -> i64
146func nx_http_server_addr_any(out: *u8, port: i64) -> i64
161func nx_http_server_listen(addr_bytes: *u8, backlog: i64,
260func nx_http_server_listen_hot(addr_bytes: *u8, backlog: i64,
310func nx_http_server_read_request(client_fd: i64,
350func nx_http_server_send_response(client_fd: i64,
366func nx_http_server_send_response_nokeep_close(
called by 7: mainmainmainmainmainmain+1 calls 1: sys_write
381func nx_http_server_accept_one(listen_fd: i64, out_verdict: *i64) -> i64
called by 32: mainad_homemainmainmaincw_home+26 calls 1: sys_accept