once the http fetch is done, close the flow (#5)

This commit is contained in:
Hannes Mehnert 2022-09-07 09:09:15 +02:00
parent 023fb4283d
commit 99dcf500c1

View file

@ -271,19 +271,21 @@ let single_request ~ctx ~alpn_protocol ?config cfg ~meth ~headers ?body uri =
| Error _ -> Mimic.add tls_config cfg ctx ) | Error _ -> Mimic.add tls_config cfg ctx )
| Error _ -> ctx in | Error _ -> ctx in
Mimic.resolve ctx >>? fun flow -> Mimic.resolve ctx >>? fun flow ->
match Option.bind (alpn_protocol flow) alpn_protocol_of_string, config with (match Option.bind (alpn_protocol flow) alpn_protocol_of_string, config with
| (Some `HTTP_1_1 | None), Some (`HTTP_1_1 config) -> | (Some `HTTP_1_1 | None), Some (`HTTP_1_1 config) ->
single_http_1_1_request ~sleep ~config flow user_pass host meth path headers body single_http_1_1_request ~sleep ~config flow user_pass host meth path headers body
| (Some `HTTP_1_1 | None), None -> | (Some `HTTP_1_1 | None), None ->
single_http_1_1_request ~sleep flow user_pass host meth path headers body single_http_1_1_request ~sleep flow user_pass host meth path headers body
| (Some `H2 | None), Some (`H2 config) -> | (Some `H2 | None), Some (`H2 config) ->
single_h2_request ~sleep ~config ~scheme flow user_pass host meth path headers body single_h2_request ~sleep ~config ~scheme flow user_pass host meth path headers body
| Some `H2, None -> | Some `H2, None ->
single_h2_request ~sleep ~scheme flow user_pass host meth path headers body single_h2_request ~sleep ~scheme flow user_pass host meth path headers body
| Some `H2, (Some (`HTTP_1_1 _)) -> | Some `H2, (Some (`HTTP_1_1 _)) ->
single_h2_request ~sleep ~scheme flow user_pass host meth path headers body single_h2_request ~sleep ~scheme flow user_pass host meth path headers body
| Some `HTTP_1_1, Some (`H2 _) -> | Some `HTTP_1_1, Some (`H2 _) ->
single_http_1_1_request ~sleep flow user_pass host meth path headers body single_http_1_1_request ~sleep flow user_pass host meth path headers body) >>= fun r ->
Mimic.close flow >|= fun () ->
r
let tls_config ?tls_config ?config authenticator = let tls_config ?tls_config ?config authenticator =
lazy ( match tls_config with lazy ( match tls_config with