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
75 stars 11 forks source link

introduce writer streams, use them in responses #68

Closed c-cube closed 1 year ago

c-cube commented 1 year ago
vphantom commented 1 year ago

So far I have only one change to request here; not sure how to suggest it "in a Git way" but: Tiny_httpd_server.ml line 397: let make_raw_writer ?(headers = []) ?(code=200) body : t = (and corresponding exposition in Tiny_httpd_server.mli so I can use it).

Rationale: all our responses will be created the same way and we will never rely on the library's built-in >300 responses for our generated content. Therefore we don't need a result wrapper and its dual "writer stream vs plain string" expectation.

c-cube commented 1 year ago

I think it's reasonable enough to use Response.make_writer (`Ok w), no? :)

vphantom commented 1 year ago

I'm not opposed to the useless wrapping in a result, but I need to be able to set that response code, hence my fiddling with code in the above.