Skip to content

Commit

Permalink
Fix usage of h2 for our server
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Sep 22, 2022
1 parent 53ddbdc commit e97256e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
6 changes: 0 additions & 6 deletions unikernel/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,3 @@ $ mirage build
$ ./dist/minipaf --tls
...
```

### Issues

Some issues persists on H2 but they already signaled to the
[ocaml-h2][ocaml-h2] maintainer. We suggest to use http/1.1 protocol or help us
to fix these issues.
6 changes: 2 additions & 4 deletions unikernel/server/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ let http_2_0_request_handler ~ctx ~authenticator ~to_close =
let content_type = H2.Headers.get request.H2.Request.headers "content-type" in
let content_type = Option.value ~default:"application/octet-stream" content_type in
let headers = H2.Headers.of_list
[ "transfer-encoding", "chunked"
; "content-type", content_type ] in
[ "content-type", content_type ] in
let response = H2.Response.create ~headers `OK in
let src = H2.Reqd.request_body reqd in
let dst = H2.Reqd.respond_with_streaming reqd response in
Expand All @@ -410,8 +409,7 @@ let http_2_0_request_handler ~ctx ~authenticator ~to_close =
let length = Int64.of_string v in
let g = Option.bind (H2.Headers.get request.H2.Request.headers "x-seed") random_state_of_seed in
let headers = H2.Headers.of_list
[ "content-type", "text/plain"
; "transfer-encoding", "chunked" ] in
[ "content-type", "text/plain" ] in
let response = H2.Response.create ~headers `OK in
let body = H2.Reqd.respond_with_streaming reqd response in
transmit_random
Expand Down
6 changes: 3 additions & 3 deletions unikernel/server/unikernel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module Make
| [ certchain ] -> Lwt.return_ok (`Single certchain)
| certchains -> Lwt.return_ok (`Multiple certchains)

let http_1_1_request_handler ~ctx ~authenticator ?shutdown:_ flow _edn =
let http_1_1_request_handler ~ctx ~authenticator flow _edn =
let module R = (val (Mimic.repr Paf.tcp_protocol)) in
fun reqd ->
match (Httpaf.Reqd.request reqd).Httpaf.Request.meth with
Expand All @@ -66,8 +66,8 @@ module Make
| R.T flow -> Paf.TLS.to_close flow
| _ -> () in
{ Alpn.error= Server.alpn_error_handler
; Alpn.request= (fun ?shutdown flow edn reqd protocol ->
Server.alpn_request_handler ~ctx ~authenticator ~to_close ?shutdown (R.T flow) edn reqd protocol) }
; Alpn.request= (fun flow edn reqd protocol ->
Server.alpn_request_handler ~ctx ~authenticator ~to_close (R.T flow) edn reqd protocol) }

let run_with_tls ~ctx ~authenticator ~tls (http_port, https_port) tcpv4v6 =
let alpn_service = Paf.alpn_service ~tls (alpn_handler ~ctx ~authenticator) in
Expand Down

0 comments on commit e97256e

Please sign in to comment.