Skip to content

Commit

Permalink
feat: move to gluon
Browse files Browse the repository at this point in the history
  • Loading branch information
leostera committed Jan 14, 2024
1 parent 5580c44 commit 4f8a367
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 5 additions & 1 deletion nomad/adapter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ let close_chunk conn =
let _ = Atacama.Connection.send conn chunk in
()

let send_file conn (req : Request.t) (res : Response.t) ?off ?len ~path () =
let send_file _conn (_req : Request.t) (_res : Response.t) ?off:_ ?len:_ ~path:_
() =
(*
let len =
match len with
| Some len -> len
Expand All @@ -235,6 +237,8 @@ let send_file conn (req : Request.t) (res : Response.t) ?off ?len ~path () =
then
let _ = Atacama.Connection.send_file conn ?off ~len (File.open_read path) in
()
*)
()

let close conn (req : Request.t) (res : Response.t) =
if req.meth = `HEAD then ()
Expand Down
5 changes: 3 additions & 2 deletions nomad/ws.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ let rec send_frames state conn frames return =
| Error `Eof ->
Logger.error (fun f -> f "ws.error: end of file");
`halt (Close state)
| Error ((`Closed | `Timeout | `Process_down | `Unix_error _) as err) ->
Logger.error (fun f -> f "ws.error: %a" Net.Socket.pp_err err);
| Error ((`Closed | `Timeout | `Process_down | `Unix_error _ | _) as err)
->
Logger.error (fun f -> f "ws.error: %a" IO.pp_err err);
`halt (Close state))

let handle_data data conn state =
Expand Down
2 changes: 2 additions & 0 deletions test/h2spec/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(executable
(name server)
(preprocess
(pps bytestring.ppx))
(libraries nomad))
4 changes: 3 additions & 1 deletion test/h2spec/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ module Test : Application.Intf = struct
sleep 0.1;
Logger.info (fun f -> f "starting nomad server");

let hello_world conn = conn |> Conn.send_response `OK "hello world" in
let hello_world conn =
conn |> Conn.send_response `OK {%b| "hello world" |}
in

let handler = Nomad.trail [ hello_world ] in

Expand Down
15 changes: 4 additions & 11 deletions test/http_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,9 @@ module Test : Application.Intf = struct
(Conn.send_chunked `OK conn)
|> Conn.close
| [ "send_chunked_200" ] ->
conn |> Conn.send_chunked `OK
|> Conn.chunk {%b|"OK"|}
|> Conn.close
conn |> Conn.send_chunked `OK |> Conn.chunk {%b|"OK"|} |> Conn.close
| [ "erroring_chunk" ] ->
let conn =
conn |> Conn.send_chunked `OK |> Conn.chunk {%b|"OK"|}
in
let conn = conn |> Conn.send_chunked `OK |> Conn.chunk {%b|"OK"|} in
Atacama.Connection.close conn.conn;
conn |> Conn.chunk {%b|"NOT OK"|}
| [ "send_file" ] ->
Expand All @@ -139,9 +135,7 @@ module Test : Application.Intf = struct
|> Conn.send_file ~off ~len `OK
~path:"./test/bandit/test/support/sendfile"
| [ "send_full_file" ] ->
conn
|> Conn.send_file `OK
~path:"./test/bandit/test/support/sendfile"
conn |> Conn.send_file `OK ~path:"./test/bandit/test/support/sendfile"
| [ "send_full_file_204" ] ->
conn
|> Conn.send_file `No_content
Expand All @@ -159,8 +153,7 @@ module Test : Application.Intf = struct
conn.req.version |> Http.Version.to_string |> Bytestring.of_string
in
conn |> Conn.send_response `OK body
| "expect_headers" :: _ ->
conn |> Conn.send_response `OK {%b|"OK"|}
| "expect_headers" :: _ -> conn |> Conn.send_response `OK {%b|"OK"|}
| "expect_no_body" :: [] ->
let[@warning "-8"] (Conn.Ok (conn, body)) = Conn.read_body conn in
assert (Bytestring.to_string body = "");
Expand Down

0 comments on commit 4f8a367

Please sign in to comment.