Simon Cruanes
a405fb046d
expose client address to websocket
2024-02-05 01:07:34 -05:00
Simon Cruanes
d3a4dbc5b0
feat server: new notion of Upgrade handler
...
this handles `connection: upgrade` endpoints with a generic
connection-oriented handler. The main goal is to support
websockets.
2024-02-05 01:06:37 -05:00
Simon Cruanes
03a2b38bad
strengthen against errors
2024-02-03 00:14:16 -05:00
Simon Cruanes
51e1d1ece5
more logging, and improved
2024-01-24 13:13:35 -05:00
Simon Cruanes
df8b579d24
feat: add Response_code.is_success
2024-01-24 13:11:47 -05:00
Simon Cruanes
bb70c46978
more detailed info string for responses
2024-01-23 23:32:21 -05:00
Simon Cruanes
729eb9c43b
info-level logging for each request
2024-01-23 23:32:21 -05:00
Simon Cruanes
86f1b9025d
add optional dependency on logs
2024-01-23 23:32:20 -05:00
barti2du
8d7dd43ba1
request: Make client_addr public
2023-12-19 12:29:16 -05:00
Simon Cruanes
b2b637041b
fix: do not block in accept
2023-12-04 15:45:18 -05:00
Simon Cruanes
18780db853
security: zero out buffers from pool before reusing them
2023-08-09 16:05:36 -04:00
Simon Cruanes
402e3f72e4
breaking: set_top_handler takes a stream request, for more generality
2023-08-08 16:36:17 -04:00
Stéphane Lavergne
03596c1a08
Remove option around client_addr
2023-08-08 15:18:39 -04:00
Stéphane Lavergne
188c21c70e
Merge branch 'c-cube:master' into client-ip
2023-08-08 14:52:14 -04:00
Simon Cruanes
572168967f
remove last qtest
2023-08-08 14:41:58 -04:00
Stéphane Lavergne
b36ea35703
Clarify why we do SIGINT/SIGHUP shenanigans
2023-08-08 14:30:39 -04:00
Stéphane Lavergne
def4414676
Remove window in which threads still got SIGINT/SIGHUP
...
At least on OCaml 4.13.1's runtime, signals are spooled until any thread
unblocks them, so we block them just before cloning, letting the thread
inherit the mask, then we unblock.
2023-08-08 14:30:39 -04:00
Stéphane Lavergne
d8234b0189
Don't let threads handle SIGINT/SIGHUP
...
It's common for applications to use these signals to trigger a graceful
shutdown.
2023-08-08 14:30:39 -04:00
Stéphane Lavergne
a7516689b1
Stop listening after accept loop
2023-08-08 14:30:39 -04:00
Simon Cruanes
1ca1f3dff9
fix: wait for threads to terminate when shutting down server
2023-08-08 14:30:39 -04:00
Simon Cruanes
1e50abb44f
Merge branch 'master' into client-ip
2023-08-08 13:03:40 -04:00
Simon Cruanes
25eb8b765a
rename IO.{In,Out}_channel to avoid confusion
...
these are not the standard in/out_channels so we should just use
different names.
2023-08-08 12:57:12 -04:00
Simon Cruanes
a3f5dde2f1
format
2023-08-08 12:37:19 -04:00
Stéphane Lavergne
1b7939c17a
Pass code to response makers
...
Error codes still override it.
2023-08-08 12:35:42 -04:00
Stéphane Lavergne
53182375c0
Preserve client address down to Request.t
...
Note that the argument is optional because of the Internal_ use case.
2023-08-07 16:52:32 -04:00
Simon Cruanes
b3b99af7ae
Merge pull request #68 from c-cube/wip-writer
...
introduce writer streams, use them in responses
2023-08-07 10:08:06 -04:00
Simon Cruanes
6070b36955
perf: use TCP_NODELAY for client sockets
...
(work with @vphantom)
2023-08-04 09:43:03 -04:00
Simon Cruanes
1060158192
do not flush after headers
2023-07-18 15:48:03 -04:00
Simon Cruanes
e3d8cf9fdd
server: use available buffer when writing body with chunk encoding
...
there's already a buffer nearby, we can use it to write streams/writer
bodies to the output channel
2023-07-18 15:40:56 -04:00
Simon Cruanes
7b094b55ad
many fixes
2023-07-11 11:31:06 -04:00
Simon Cruanes
de23d9b2a3
wip: add IO.Writer.t, a push based stream
...
This is more convenient than our existing streams when it comes to
writing a body. The user can just get an output channel and write to it,
flush it, etc. as they please. This should also simplify compression…
once it works.
2023-07-11 10:57:08 -04:00
Simon Cruanes
ec2f2f6f2e
add Server.run_exn
2023-07-11 10:01:33 -04:00
Simon Cruanes
b9faebffe4
use a resource pool to recycle buffers
2023-06-23 17:58:11 -04:00
Simon Cruanes
79cbcca4c1
cleanup: remove unused function in Tiny_httpd_server.IO_BACKEND
2023-06-21 00:23:11 -04:00
Simon Cruanes
5d7637becc
server: add IO_BACKEND abstraction; implement a unix version of it
...
this doesn't change the `create`+`run` version, but makes it possible to
create a server that doesn't use unix IOs.
2023-06-20 23:03:31 -04:00
Simon Cruanes
ee310b5262
fix: description for 401 code
2023-06-20 23:03:29 -04:00
Simon Cruanes
88bfb9c109
feat: Server.run takes ?after_init parameter
...
also use it in http_of_dir to print the actual port.
2023-05-24 15:38:38 -04:00
Simon Cruanes
0908d71e19
ocamlformat
2023-05-23 17:40:18 -04:00
Simon Cruanes
30a355da5a
fix: SSE requires no body
2023-05-23 17:39:19 -04:00
Simon Cruanes
997f7aa868
expose Response.make_void
...
it only has no body if the http code is compatible with it.
close #62
2023-05-23 17:18:05 -04:00
Stephane Legrand
9c2cf0900d
Add OPTIONS method
2023-05-07 20:55:46 -04:00
Simon Cruanes
53032c993e
fix: get addr/port from the current socket
2023-04-03 12:32:13 -04:00
craff
095487ce85
close stream after Response.output
2023-01-18 17:06:25 -10:00
craff
8c7b764b30
forgot to catch Unix_error
2022-12-09 07:36:05 -10:00
craff
915317438f
use directly file descriptor for input to avoid stacking buffers
2022-12-09 03:17:51 -10:00
Simon Cruanes
d5f9eacc81
split code into more modules
2022-03-16 20:40:38 -04:00