Add HTTP server builtins (net.http.serve or net.http.listen/accept/respond) #476
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq#476
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
net.http.*exposes only the client side:get,post,put,delete. There is no way for a Seq program to serve HTTP without dropping down to raw TCP and the response-formatting helpers instdlib/http.seq. Mirror of the TCP-client gap, but in the opposite direction.Current state
All client.
crates/compiler/stdlib/http.seqprovides response-line and request-parsing helpers (http-ok,http-not-found,http-request-path, etc.) — these only make sense if the user has already accepted a TCP connection, read the raw bytes, and is hand-rolling an HTTP/1.1 server. That works, but it is exactly the kind of "you can build it from primitives" answer thatnet.http.getwas created to avoid on the client side.Proposed shape
Open to discussion — a few plausible designs:
A. Handler-quotation server (simplest)
Handler receives a request map
{ method, path, headers, body }, returns a response map{ status, body, content-type, headers }. Blocks the calling strand; user spawns it explicitly.B. Lower-level accept loop
More verbose but composes with channels and spawn the way the rest of
net.*does.C. None of the above — leave HTTP server in user-land on top of TCP, but at least promote
stdlib/http.seqto a realinclude std:httpstory with request parsing that doesn't require hand-splitting on\r\n.Motivation
Less urgent than the TCP-client gap (no seqlings chapter is currently broken by it), but the asymmetry is jarring:
Filed separately from the TCP gap to keep the conversations focused. The TCP issue is the immediate blocker; this one is the symmetry argument.
#485