# Client request expiry in ocaml using cohttp

**URL:** <https://discuss.ocaml.org/t/client-request-expiry-in-ocaml-using-cohttp/5568>\
**Category:** Learning\
**Created:** [April 19, 2020, 7:44pm UTC](https://discuss.ocaml.org/t/client-request-expiry-in-ocaml-using-cohttp/5568 "2020-04-19T19:44:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahana123](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@sahana123](https://discuss.ocaml.org/u/sahana123)\
**Post date:** [April 19, 2020, 7:44pm UTC](https://discuss.ocaml.org/t/client-request-expiry-in-ocaml-using-cohttp/5568/1 "2020-04-19T19:44:50Z")

</div>

I am trying to create a client using the code given the github repository. [https://github.com/mirage/ocaml-cohttp](https://github.com/mirage/ocaml-cohttp)

How do I make the request to expire after some time(1 minute)?

(\* client\_example.ml \*)  
open Lwt  
open Cohttp  
open Cohttp\_lwt\_unix

let body =  
Client.get (Uri.of\_string “[https://www.reddit.com/](https://www.reddit.com/)”) \>\>= fun (resp, body) -\>  
let code = resp |\> Response.status |\> Code.code\_of\_status in  
Printf.printf “Response code: %d\n” code;  
Printf.printf “Headers: %s\n” (resp |\> Response.headers |\> Header.to\_string);  
body |\> Cohttp\_lwt.Body.to\_string \>|= fun body -\>  
Printf.printf “Body of length: %d\n” (String.length body);  
body

let () =  
let body = Lwt\_main.run body in  
print\_endline (“Received body\n” ^ body)

---

<div class="post-metadata">

**Author:** ![CraigFe](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/craigfe/32/1989_2.png) [@CraigFe](https://discuss.ocaml.org/u/CraigFe)\
**Post date:** [April 20, 2020, 1:35pm UTC](https://discuss.ocaml.org/t/client-request-expiry-in-ocaml-using-cohttp/5568/2 "2020-04-20T13:35:29Z")

</div>

See [https://github.com/mirage/ocaml-cohttp/issues/691#issuecomment-616503727](https://github.com/mirage/ocaml-cohttp/issues/691#issuecomment-616503727).
