Skip to content

feat(http): CgiHandler + refacto structure src/http#18

Merged
byronlove111 merged 2 commits into
mainfrom
feat/http-cgi
Jun 17, 2026
Merged

feat(http): CgiHandler + refacto structure src/http#18
byronlove111 merged 2 commits into
mainfrom
feat/http-cgi

Conversation

@byronlove111

Copy link
Copy Markdown
Collaborator

Summary

  • CgiHandler : fork + execve + pipes stdin/stdout + env vars CGI/1.1
  • Détection automatique par extension (.py, .php) via isCgiRequest()
  • buildEnv : REQUEST_METHOD, QUERY_STRING, CONTENT_LENGTH, SCRIPT_FILENAME...
  • parseOutput : parse headers CGI + body, gère Status: custom
  • Refacto src/http/ en sous-dossiers : parser/, router/, handlers/, cgi/, response/
  • Script de démo www/cgi-bin/hello.py (GET query string + POST body)

Tests

13 tests CGI couvrant GET, POST, query string, 404, 403, 405.

Total : 107/107 tests passent.

Test plan

  • GET /cgi-bin/hello.py?name=Byron → 200 + "Bonjour Byron"
  • POST /cgi-bin/hello.py avec body → body reçu dans la réponse
  • Script inexistant → 404
  • Script non exécutable → 403
  • Méthode non autorisée → 405
  • URI .html sur même route → GET classique, pas de CGI

Made with Cursor

byronlove111 and others added 2 commits June 17, 2026 02:28
- Add CgiHandler: fork/execve, pipes stdin/stdout, env vars, parse output
- Connect CgiHandler in MethodHandler dispatch (isCgiRequest)
- Refactor src/http/ into subdirs: parser/, router/, handlers/, cgi/, response/
- Add www/cgi-bin/hello.py — demo script (GET query string + POST body)
- Add 13 CGI unit tests

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@byronlove111 byronlove111 merged commit 0c6c370 into main Jun 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant