My agentic slop goes here. Not intended for anyone else!

fix

Changed files
+26 -27
stack
requests
lib
+26 -27
stack/requests/lib/one.ml
···
let method_str = Method.to_string method_ in
Log.info (fun m -> m "Making %s request to %s" method_str url);
-
(* Parse URI *)
-
let uri = Uri.of_string url in
-
let host = match Uri.host uri with
-
| Some h -> h
-
| None -> failwith "URL must contain a host"
-
in
-
let port = match Uri.scheme uri, Uri.port uri with
-
| Some "https", None -> 443
-
| Some "https", Some p -> p
-
| Some "http", None -> 80
-
| Some "http", Some p -> p
-
| _, Some p -> p
-
| _ -> 80
-
in
-
(* Prepare headers *)
let headers = match headers with
| Some h -> h
···
| None -> headers
in
-
(* Create endpoint for connection pool *)
-
let endpoint = Conpool.Endpoint.make ~host ~port in
-
(* Convert body to string for sending *)
let request_body_str = match body with
| None -> ""
| Some b -> Body.Private.to_string b
in
-
-
(* Determine if we need TLS based on URL scheme and choose appropriate pool *)
-
let is_https = match Uri.scheme uri with
-
| Some "https" -> true
-
| _ -> false
-
in
-
-
(* Choose the appropriate connection pool *)
-
let pool = if is_https then client.https_pool else client.http_pool in
(* Execute request with pooled connection *)
let rec make_with_redirects url_to_fetch redirects_left =
let uri_to_fetch = Uri.of_string url_to_fetch in
+
+
(* Parse the redirect URL to get correct host and port *)
+
let redirect_host = match Uri.host uri_to_fetch with
+
| Some h -> h
+
| None -> failwith "Redirect URL must contain a host"
+
in
+
let redirect_port = match Uri.scheme uri_to_fetch, Uri.port uri_to_fetch with
+
| Some "https", None -> 443
+
| Some "https", Some p -> p
+
| Some "http", None -> 80
+
| Some "http", Some p -> p
+
| _, Some p -> p
+
| _ -> 80
+
in
+
+
(* Create endpoint for this specific URL *)
+
let endpoint = Conpool.Endpoint.make ~host:redirect_host ~port:redirect_port in
+
+
(* Determine if we need TLS based on this URL's scheme *)
+
let is_https = match Uri.scheme uri_to_fetch with
+
| Some "https" -> true
+
| _ -> false
+
in
+
+
(* Choose the appropriate connection pool for this URL *)
+
let pool = if is_https then client.https_pool else client.http_pool in
let make_request_fn () =
Conpool.with_connection pool endpoint (fun flow ->