+291
stack/requests/lib/digest_auth.ml
+291
stack/requests/lib/digest_auth.ml
···
···+module Log = (val Logs.src_log (Logs.Src.create "requests.digest_auth" ~doc:"HTTP Digest Authentication") : Logs.LOG)
+2
-1
stack/requests/lib/dune
+2
-1
stack/requests/lib/dune
+259
-103
stack/requests/lib/requests.ml
+259
-103
stack/requests/lib/requests.ml
·································let req_client = create_client ?tls_config:t.tls_config ~default_headers:t.headers ~clock:t.clock t.net in······Log.debug (fun m -> m "Streaming download from %s with chunk size %d" (Uri.to_string uri) chunk_size);···
·········+let digest ~username ~password = DigestAuth { username; password; challenge = ref (None : string option) }···+Digest_auth.apply_digest_auth ~username ~password ~meth ~uri ~headers ~body:None ~challenge_header)·········+let create ?(tls_config=Tls.default ()) ?(default_headers=Cohttp.Header.init ()) ?cache ~clock net =+let create_with_cache ~sw ?(tls_config=Tls.default ()) ?(default_headers=Cohttp.Header.init ())···+| DigestAuth { username = _; password = _; challenge } when result.Response.status = `Unauthorized ->·········let req_client = create_client ?tls_config:t.tls_config ~default_headers:t.headers ~clock:t.clock t.net in······Log.debug (fun m -> m "Streaming download from %s with chunk size %d" (Uri.to_string uri) chunk_size);···+Log.debug (fun m -> m "Downloading file from %s to %s" (Uri.to_string uri) (Eio.Path.native_exn path));+Log.debug (fun m -> m "Attempting resumable download from %s to %s" (Uri.to_string uri) (Eio.Path.native_exn path));
+83
-1
stack/requests/lib/requests.mli
+83
-1
stack/requests/lib/requests.mli
············
············
+504
stack/requests/lib/requests_cache.ml
+504
stack/requests/lib/requests_cache.ml
···
···+module Log = (val Logs.src_log (Logs.Src.create "requests.cache" ~doc:"HTTP cache with cacheio") : Logs.LOG)+memory_cache : (string, Requests_types.Response.t * float) Hashtbl.t; (* Memory cache fallback *)+let create ~sw ~enabled ?(cache_get_requests=true) ?(cache_range_requests=true) ~cache_dir () =+let status_code = json |> Yojson.Basic.Util.member "status_code" |> Yojson.Basic.Util.to_int in+let headers_json = json |> Yojson.Basic.Util.member "headers" |> Yojson.Basic.Util.to_assoc in+else if is_cacheable ~method_ ~status:response.Requests_types.Response.status ~headers:response.headers then
+34
stack/requests/lib/requests_types.ml
+34
stack/requests/lib/requests_types.ml
···
···
+4
-4
stack/requests/test/dune
+4
-4
stack/requests/test/dune
+226
stack/requests/test/test_cache.ml
+226
stack/requests/test/test_cache.ml
···
···+let url = Uri.of_string "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" in+Printf.printf " Status: %s\n" (Cohttp.Code.string_of_status ((Requests.Response.status response1)));+Printf.printf " Status: %s\n" (Cohttp.Code.string_of_status (Requests.Response.status response2));+let url = Uri.of_string "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" in+Printf.printf " Status: %s\n" (Cohttp.Code.string_of_status (Requests.Response.status response1));+let nocache_url = Uri.of_string "https://httpbin.org/response-headers?Cache-Control=no-cache" in+Printf.printf " Status: %s\n" (Cohttp.Code.string_of_status (Requests.Response.status response2));+let cache = Requests.Requests_cache.create ~sw ~enabled:true ~cache_dir:(Some cache_dir) () in+Requests.Requests_cache.put cache ~method_:`GET ~url ~request_headers:(Cohttp.Header.init ()) ~response;+let cached = Requests.Requests_cache.get cache ~method_:`GET ~url ~headers:(Cohttp.Header.init ()) in+let cached2 = Requests.Requests_cache.get cache ~method_:`GET ~url ~headers:(Cohttp.Header.init ()) in
+136
stack/requests/test/test_cache_integration.ml
+136
stack/requests/test/test_cache_integration.ml
···
···
+28
stack/requests/test/test_rng.ml
+28
stack/requests/test/test_rng.ml
···
···
+11
stack/requests/test/test_rng_simple.ml
+11
stack/requests/test/test_rng_simple.ml
···
···
+78
stack/requests/test/test_simple_cache.ml
+78
stack/requests/test/test_simple_cache.ml
···
···+Printf.printf " Status: %s\n" (Cohttp.Code.string_of_status cached.Requests.Requests_types.Response.status);+let has_complete = Requests.Requests_cache.has_complete cache ~url:chunk_url ~total_size:200L in
+87
stack/requests/test/test_streaming.ml
+87
stack/requests/test/test_streaming.ml
···
···+traceln "File content preview: %s" (String.sub file_content 0 (min 100 (String.length file_content)));+traceln "Original response body size: %d bytes" (String.length (Requests.Response.body response));