@@ -147,12 +147,11 @@ module HttpStore = struct
147147 (* let size t key =
148148 let tries = t.tries and client = t.client and config = t.config in
149149 let url = t.base_url ^ key in
150- print_endline @@ "about to HEAD " ^ url;
151- let res = Ezcurl.http ~tries ~client ~config ~url ~meth:HEAD () in
150+ let type' = if String.ends_with ~suffix:".json" key then "json" else "octet-stream" in
151+ let headers = [("Content-Type", "application/" ^ type')] in
152+ let res = Ezcurl.http ~headers ~tries ~client ~config ~url ~meth:HEAD () in
152153 match fold_result res with
153- | {code; _} when code = 404 ->
154- print_endline "akho head";
155- 0
154+ | {code; _} when code = 404 -> 0
156155 | {headers; _} ->
157156 match List.assoc_opt "content-length" headers with
158157 | (Some "0" | None) ->
@@ -177,7 +176,11 @@ module HttpStore = struct
177176 let set t key data =
178177 let tries = t.tries and client = t.client and config = t.config
179178 and url = t.base_url ^ key and content = `String data in
180- let res = Ezcurl. post ~params: [] ~tries ~client ~config ~url ~content () in
179+ let type ' = if String. ends_with ~suffix: " .json" key then " json" else " octet-stream" in
180+ let headers =
181+ [(" Content-Length" , string_of_int (String. length data))
182+ ;(" Content-Type" , " application/" ^ type ')] in
183+ let res = Ezcurl. post ~params: [] ~headers ~tries ~client ~config ~url ~content () in
181184 match fold_result res with
182185 | {code; _} when code = 200 || code = 201 -> ()
183186 | {code; body; _} -> raise (Request_failed (code, body))
@@ -212,10 +215,11 @@ module HttpStore = struct
212215 let rename _ = raise Not_implemented
213216 end
214217
215- let with_open ?(redirects =5 ) ?(tries =3 ) url f =
218+ let with_open ?(redirects =5 ) ?(tries =3 ) ?( timeout = 5 ) url f =
216219 let config = Ezcurl_core.Config. (default |> max_redirects redirects |> follow_location true ) in
217220 let perform client = f IO. {tries; client; config; base_url = url ^ " /" } in
218- Ezcurl_core. with_client perform
221+ let set_opts client = Curl. set_connecttimeout client timeout in
222+ Ezcurl_core. with_client ~set_opts perform
219223
220224 include Zarr.Storage. Make (IO )
221225end
0 commit comments