From 52c6918c139232ebc4239c156bbf76e00a197530 Mon Sep 17 00:00:00 2001 From: Adelyn Breedlove Date: Sun, 17 Feb 2019 21:18:18 -0700 Subject: Fix an issue where routes that don't return rate limit info lock forever --- lib/http/http.ml | 8 ++++---- lib/http/rl.ml | 2 +- lib/http/rl.mli | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/http/http.ml b/lib/http/http.ml index 5288aac..ced2810 100644 --- a/lib/http/http.ml +++ b/lib/http/http.ml @@ -27,10 +27,10 @@ module Base = struct ] let process_response path ((resp:Response.t), body) = - (match Response.headers resp - |> Rl.rl_of_header with - | Some r -> Mvar.put (Rl.find_exn !rl path) r - | None -> return ()) + let limit = match Response.headers resp |> Rl.rl_of_header with + | Some r -> r + | None -> Rl.default + in Mvar.put (Rl.find_exn !rl path) limit >>= fun () -> match resp |> Response.status |> Code.code_of_status with | 204 -> Deferred.Or_error.return `Null diff --git a/lib/http/rl.ml b/lib/http/rl.ml index f0c15be..6c61953 100644 --- a/lib/http/rl.ml +++ b/lib/http/rl.ml @@ -7,7 +7,7 @@ type rl = { limit: int; remaining: int; reset: int; -} +} [@@deriving sexp] type t = ((rl, read_write) Mvar.t) RouteMap.t diff --git a/lib/http/rl.mli b/lib/http/rl.mli index 973f02f..a0facb3 100644 --- a/lib/http/rl.mli +++ b/lib/http/rl.mli @@ -11,7 +11,7 @@ type rl = { limit: int; remaining: int; reset: int; -} +} [@@deriving sexp] (** Type representing the specific case of {!RouteMap}. *) type t = ((rl, read_write) Mvar.t) RouteMap.t -- cgit v1.2.3