Closed craff closed 2 years ago
It seems to work in my application...
I'm sorry, I don't like this being in the httpd itself. Headers are already present and give all the information needed. I could imagine a Tiny_httpd_cookies
module with the types, parsers, and printers. However, I think this is more on the "web framework" level anyway, so there probably should be a different package with sessions, cookies, DB connections, etc. instead of putting everything in the httpd.
Then, I would propose a header handler called at each time we parse the header ( to avoid searching the list of pairs), the default handler being the current behaviour.
I want the user to be able not to search the list of pairs, which can be fairly long.
I will update the PR shortly, if you like this solution.
Le 24 décembre 2021 15:52:54 GMT+01:00, Simon Cruanes @.***> a écrit :
I'm sorry, I don't like this being in the httpd itself. Headers are already present and give all the information needed. I could imagine a
Tiny_httpd_cookies
module with the types, parsers, and printers. However, I think this is more on the "web framework" level anyway, so there probably should be a different package with sessions, cookies, DB connections, etc. instead of putting everything in the httpd.-- Reply to this email directly or view it on GitHub: https://github.com/c-cube/tiny_httpd/pull/38#issuecomment-1000865815 You are receiving this because you authored the thread.
Message ID: @.***>
I think it'd be better to take a leaf of dream's book and use a hmap (a small reimplementation takes a few dozen lines) to carry data around with the queries. Then you can make a middleware that parses cookies and provides a cookie variable
to inner layers, including the final query handler.
On 21-12-30 19:30:06, Simon Cruanes wrote:
I think it'd be better to take a leaf of dream's book and use a hmap (a small reimplementation takes a few dozen lines) to carry data around with the queries. Then you can make a middleware that parses cookies and provides a cookie variable to inner layers, including the final query handler.
Hello,
I have decided not to do anything yet. My application is working, the main bug is solved and the code is OK.
But with multicore coming, tiny_httpd starts to be real fast (I refer to the branch testing it). I thing a good idea would be to parse the header directly from the byte stream. So instead of offering a list of pairs, to offer a way to customize a parser combinator with a good ppx to have readable parsers.
Pacomb offers extensibla parsers and is really fast while compiled at runtime for the moment (it is around 2x slower than menhir). Remark: pacomb is the only parser combinator that is suitable for streams because it compiles and optimize BNF (even left recursive ones) to parser combinator that do not backtrack, which is compatible with streams.
An even better solution would be to compile the parser combinator at runtime (this should be faster than menhir). This would allow a lightweight and very fast solution for httpd in OCaml (I really think ligthweight is necessary for a fast software).
My plan is
wait for multicore to be usable from opam (I failed to install ocaml-5.0-trunk, do not know why)
wait for pacomb to support compile time compilation of BNF.
then offer a version of tiny_httpd than is parser based and check it is actually faster and easier to use compared to storing strings (It happens often that good idea ... fails)
In the meanwhile, I can probably work on some other issue for Tiny_httpd.
Cheers, Christophe
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.*Message ID: <c-cube/ @.***>
-- Christophe Raffalli tél: +689 87 23 11 48 web: http://raffalli.eu
It needs testing ...