c-cube / tiny_httpd

Minimal HTTP server using good old threads + blocking IO, with a small request router.
https://c-cube.github.io/tiny_httpd
76 stars 11 forks source link

session and handling of body in post method #20

Closed craff closed 1 year ago

craff commented 2 years ago

Two features which are almost always needed are not provided:

c-cube commented 2 years ago

You're not missing anything, this is really just the httpd part. I think it'd be interesting, maybe, to build a higher-level library on top of it to handle sessions, etc. but this might be scope creep (for a realistic full website you might be better using Dream directly). If you write API endpoints, otoh, this should be enough with maybe a thin session layer, but no multipart?

craff commented 2 years ago

I saw you are preparing a release ... I have some code both for parsing multipart post request and for session. Both are very light I think and would fit at this level of the library.

I could move the first code in Util where there is already a parser for GET request and add my code for session in a new module. But both needs some work.

Would you like me to submit pull request before or after the release ?

c-cube commented 2 years ago

It's already released, look on opam :).

craff commented 2 years ago

The code is rather small and now in Tiny_httpd_util where there is parse_query. I push a PR, you will see, I actually cleaned the code and mover it in Tiny_httpd on my fork.

I used Str, via a thread safe interface (using mutex). It is much easier that way.

It would be better to use a real regexp library or maybe use pacomb for that. But I feel you want (and I wand) minimum dependency beside Ocaml Stdlib's

craff commented 2 years ago

For session. I am not sure what to do exactly. May be just function for cookies, and let the user manage session. That could be very simple.

craff commented 2 years ago

PR #38 should be enough for now

craff commented 1 year ago

You may close this too.