File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 11module type S = sig
22 exception Not_implemented
33 exception Request_failed of int * string
4+ type auth = {user : string ; pwd : string }
45 include Storage .STORE
56
67 val with_open :
8+ ?basic_auth : auth ->
79 ?redirects : int ->
810 ?tries : int ->
911 ?timeout : int ->
@@ -141,10 +143,18 @@ module Make
141143 let rename _ = raise Not_implemented
142144 end
143145
144- let with_open ?(redirects =5 ) ?(tries =3 ) ?(timeout =5 ) url f =
145- let config = Ezcurl_core.Config. (default |> max_redirects redirects |> follow_location true ) in
146- let perform client = f IO. {tries; client; config; base_url = url ^ " /" } in
146+ type auth = {user : string ; pwd : string }
147+ let noauth = {user = " " ; pwd = " " }
148+
149+ let with_open ?(basic_auth =noauth) ?(redirects =5 ) ?(tries =3 ) ?(timeout =5 ) url f =
147150 let set_opts client = Curl. set_connecttimeout client timeout in
151+ let perform client =
152+ let config = Ezcurl_core.Config. (
153+ default |> max_redirects redirects |> follow_location true |>
154+ username basic_auth.user |> password basic_auth.pwd
155+ ) in
156+ f IO. {tries; client; config; base_url = url ^ " /" }
157+ in
148158 C. with_client ~set_opts perform
149159
150160 include Storage. Make (IO )
You can’t perform that action at this time.
0 commit comments