http_static: a prefix with a trailing slash matches no file, and nothing says so

Offen Anfängerfreundlich
#2,356 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
62/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
c
Bereich
backend

Rechercherichtung

Beginne mit der Routenprüfung in src/ext_http.c, bei der das Byte nach dem registrierten Präfix / sein oder das Ende des Pfads sein muss. Reproduziere das Problem mit einer einzelnen Registrierung http_static of ["/s1/", "files"] und einem GET auf /s1/a.txt, der 404 liefern sollte. Wähle eines der beiden Ergebnisse, die das Issue zulässt: entweder die Form mit abschließendem Schrägstrich abzugleichen oder sie bei der Registrierung abzulehnen, und halte die Wahl in docs/BUILTINS.md fest. Fertig ist, wenn beide Schreibweisen durch einen Test abgedeckt sind, der einen Server startet und eine Datei abruft.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area:http kind:bug

Found by a consumer's HTTP server at 54008422.

What happens

http_static of [prefix, dir] serves the files of dir under prefix. A prefix written with a trailing slash matches no file. With files/a.txt present:

http_static of ["/s1/", "files"]
http_serve of 3000

GET /s1/a.txt answers 404 ({"error": "not_found"}). The same program with the prefix "/s1" answers 200. The route check in src/ext_http.c asks that the byte after the whole prefix be / or the end of the path, and after /s1/ the next byte is the file's first letter.

Why it matters

Both spellings are common, nothing is printed at registration, and the 404 is the same one an unknown path gets. A page that loads its script from such a prefix simply has no script.

Done when

  • http_static with a trailing slash on the prefix serves the same files as without it, or refuses the prefix at registration with an error that names it.
  • docs/BUILTINS.md says which form the prefix takes.
  • A test starts one server for each spelling and fetches a file under it.

Corrected 2026-11-12. The first text of this issue registered both spellings in one program and read the 404 for /s1/ there. That program cannot show it: a second http_static replaces the first (#2357), so /s1/ would have answered 404 with or without its slash. The single registration above was run afterwards and answers 404 as described.

Vorherrschende Sprache
C
Sterne
3
Forks
7
Ø Merge
3 Std. 30 Min.
Gemergte PRs (30 T.)
264

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus InauguralSystems/EigenScript

Alle Issues in InauguralSystems/EigenScript

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.