diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dune | 2 | ||||
| -rw-r--r-- | lib/http.ml | 4 | ||||
| -rw-r--r-- | lib/sharder.ml | 2 |
3 files changed, 6 insertions, 2 deletions
@@ -20,7 +20,7 @@ event_models
client client_options disml dispatch endpoints event http impl opcode rl s sharder
)
- (libraries checkseum.c core async_ssl cohttp-async decompress logs yojson websocket-async ppx_deriving_yojson.runtime)
+ (libraries checkseum.ocaml core async_ssl cohttp-async decompress logs yojson websocket-async ppx_deriving_yojson.runtime)
(preprocess (pps ppx_sexp_conv ppx_deriving_yojson))
)
diff --git a/lib/http.ml b/lib/http.ml index 5e49843..283ab69 100644 --- a/lib/http.ml +++ b/lib/http.ml @@ -33,9 +33,11 @@ module Base = struct | None -> return ())
>>= fun () ->
match resp |> Response.status |> Code.code_of_status with
- | 200 -> body |> Cohttp_async.Body.to_string >>| Yojson.Safe.from_string >>= Deferred.Or_error.return
+ | code when Code.is_success code -> body |> Cohttp_async.Body.to_string >>| Yojson.Safe.from_string >>= Deferred.Or_error.return
| code ->
body |> Cohttp_async.Body.to_string >>= fun body ->
+ let headers = Response.sexp_of_t resp |> Sexp.to_string_hum in
+ Logs.warn (fun m -> m "[Unsuccessful Response] [Code: %d]\n%s\n%s" code body headers);
Deferred.Or_error.errorf "Unsuccessful response received: %d - %s" code body
let request ?(body=`Null) ?(query=[]) m path =
diff --git a/lib/sharder.ml b/lib/sharder.ml index 157967d..d4e6bd1 100644 --- a/lib/sharder.ml +++ b/lib/sharder.ml @@ -279,6 +279,8 @@ module Shard = struct let shutdown_clean shard =
let (_,w) = shard._internal in
+ Pipe.write (snd shard.pipe) (Frame.create ~opcode:(Frame.Opcode.Close) ~final:true ())
+ >>= fun _ ->
Ivar.fill shard.hb_stopper ();
Writer.close w
|