diff options
| author | user <user@clank> | 2026-09-22 17:12:52 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-22 17:12:52 +0200 |
| commit | 30e67fe0f4e66e2161ca61f870f8947d50287995 (patch) | |
| tree | a04189f34687a4d600903100feca18aedc5d1604 /src/programs.asm | |
| parent | net: passive open (listen/accept) + own sockets + close promptly (diff) | |
| download | gbos-30e67fe0f4e66e2161ca61f870f8947d50287995.tar.gz gbos-30e67fe0f4e66e2161ca61f870f8947d50287995.tar.xz gbos-30e67fe0f4e66e2161ca61f870f8947d50287995.zip | |
usr: httpd - the Game Boy serves its filesystem over HTTP
/# httpd &
host$ curl http://10.0.0.2/ -> a listing of the cart RAM
host$ curl http://10.0.0.2/readme -> the file, from battery-backed SRAM
GET only. "/" serves /index.html if present, else a generated listing; any
directory lists with every entry linked, so you can click around a 1997
handheld's disk from a browser. Content type from the extension. No
Content-Length: HTTP/1.0 + Connection: close delimits the body by closing,
which suits a stack with one in-flight segment.
All output goes through one 200-byte buffer, so each net_send is a full
segment instead of one tiny segment per string.
It drains the whole request, not just the request line. That is not
politeness: leaving the rest unread means those segments are never
acknowledged, so the client retransmits headers for a minute, never sends
its FIN, and its dead connection keeps arriving at port 80 long after we
re-listen. One curl with 1.4 KB of headers stalled every following request
for 30-120s.
It deliberately does NOT read the keyboard either. Backgrounded - the useful
way to run it - every key it polled would be a key stolen from the shell's
prompt. It is a daemon: kill(1) stops it, and the kernel reclaims its socket.
Verified with curl: index, byte-exact file bodies, nested paths, directory
listings, 404, 501, a 1.4 KB request spanning segments, browser user-agents,
three parallel clients (0.1/1.1/2.1s), the shell staying usable alongside it,
and six kill/restart cycles - more than there are sockets.
Diffstat (limited to '')
| -rw-r--r-- | src/programs.asm | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/programs.asm b/src/programs.asm index a3bd680..31125a2 100644 --- a/src/programs.asm +++ b/src/programs.asm @@ -151,6 +151,9 @@ ProgCp: SECTION "prog_nc", ROMX[$4000], BANK[38] ProgNc: INCBIN "build/usr/nc.bin" +SECTION "prog_httpd", ROMX[$4000], BANK[39] +ProgHttpd: + INCBIN "build/usr/httpd.bin" ; ----------------------------------------------------------------------------- ; PROG_SH (bank 3) - the shell, now written in C (usr/sh.c): parses >/</| and @@ -267,6 +270,8 @@ ProgramTable:: dw ProgCp db LOW(BANK(ProgNc)), HIGH(BANK(ProgNc)) dw ProgNc + db LOW(BANK(ProgHttpd)), HIGH(BANK(ProgHttpd)) + dw ProgHttpd ProgramTableEnd:: ; ----------------------------------------------------------------------------- @@ -348,4 +353,6 @@ NameTable:: db PROG_CP db "nc", 0 db PROG_NC + db "httpd", 0 + db PROG_HTTPD db 0 |
