http.bend fails
raw source on the hub · import 0xd66ee682d4ce8c656782ca9e0e4634cb/http.bend as Http
HTTP lib over the existing TCP kit (no TLS, no DNS).
Reuses Base (String/List/U32/Nat/TCP/Socket/IO) and the two demos: - io_http_fetch's blank-line cut (window word 218762506 = "\r\n\r\n") - io_http_server's per-connection spawn + response shape.
Import as: import ../lib/http.bend as HTTP Then HTTP.read_url, HTTP.get_header, HTTP.fetch, ...
Discipline (user-land Bend has no Base carve-out): - every callee is defined ABOVE its caller; only self-recursion. - match scrutinees are params or pattern-bound vars, never computed. - helpers above drivers are leaves: they never call back down.
Security policy (fail-closed): - show_* rejects CRLF in every field (injection) with Fail 400. - read_* caps the head at 16KB; oversize is Fail 413. - ports must be 1..65535; hosts reject whitespace and controls. - https:// parses but fetch refuses with 501 (no TLS yet). - fetch reads at most 8x8192 bytes (64KB cap), then truncates. - TCP kit has no DNS: use IPs or localhost (see demos/io_http_fetch).
2 imports
import Base import ./tcp.bend as TCP
The reader could not load this file (at 0xd66ee682d4ce8c656782ca9e0e4634cb/http.bend:1828). What bend.ts says:
Error:
- expected : an unambiguous name (the alias TCP shadows TCP.recv_bytes)
- observed : '('
Location:
1827 | def fetch.recv8(sock: Socket, meth: String, acc: List<&2, U32>) -> IO(Result<&1, &1, U32 & String, String>):
1828>| IO.bind(Socket & Result<&1, &1, U32 & String, List<&2, U32>>, Result<&1, &1, U32 & String, String>, TCP.recv_bytes(sock, 8192), m => fetch.after8fn(meth, acc, m))
| ^
1829 |