44
55use cached:: proc_macro:: cached;
66use clap:: { Arg , ArgAction , Command } ;
7- use std:: str:: FromStr ;
87use std:: sync:: LazyLock ;
98
109use futures_lite:: FutureExt ;
11- use hyper:: Uri ;
1210use hyper:: { header:: HeaderValue , Body , Request , Response } ;
1311use log:: { info, warn} ;
1412use redlib:: client:: { canonical_path, proxy, rate_limit_check, CLIENT } ;
@@ -433,11 +431,19 @@ pub async fn proxy_commit_info() -> Result<Response<Body>, String> {
433431
434432#[ cached( time = 600 ) ]
435433async fn fetch_commit_info ( ) -> String {
436- let uri = Uri :: from_str ( "https://github.com/redlib-org/redlib/commits/main.atom" ) . expect ( "Invalid URI" ) ;
437-
438- let resp: Body = CLIENT . get ( uri) . await . expect ( "Failed to request GitHub" ) . into_body ( ) ;
439-
440- hyper:: body:: to_bytes ( resp) . await . expect ( "Failed to read body" ) . iter ( ) . copied ( ) . map ( |x| x as char ) . collect ( )
434+ // wreq uses http v1.x: pass URL as &str and call .send().await, then .bytes().await
435+ CLIENT
436+ . get ( "https://github.com/redlib-org/redlib/commits/main.atom" )
437+ . send ( )
438+ . await
439+ . expect ( "Failed to request GitHub" )
440+ . bytes ( )
441+ . await
442+ . expect ( "Failed to read body" )
443+ . iter ( )
444+ . copied ( )
445+ . map ( |x| x as char )
446+ . collect ( )
441447}
442448
443449pub async fn proxy_instances ( ) -> Result < Response < Body > , String > {
@@ -452,9 +458,17 @@ pub async fn proxy_instances() -> Result<Response<Body>, String> {
452458
453459#[ cached( time = 600 ) ]
454460async fn fetch_instances ( ) -> String {
455- let uri = Uri :: from_str ( "https://raw.githubusercontent.com/redlib-org/redlib-instances/refs/heads/main/instances.json" ) . expect ( "Invalid URI" ) ;
456-
457- let resp: Body = CLIENT . get ( uri) . await . expect ( "Failed to request GitHub" ) . into_body ( ) ;
458-
459- hyper:: body:: to_bytes ( resp) . await . expect ( "Failed to read body" ) . iter ( ) . copied ( ) . map ( |x| x as char ) . collect ( )
461+ // wreq uses http v1.x: pass URL as &str and call .send().await, then .bytes().await
462+ CLIENT
463+ . get ( "https://raw.githubusercontent.com/redlib-org/redlib-instances/refs/heads/main/instances.json" )
464+ . send ( )
465+ . await
466+ . expect ( "Failed to request GitHub" )
467+ . bytes ( )
468+ . await
469+ . expect ( "Failed to read body" )
470+ . iter ( )
471+ . copied ( )
472+ . map ( |x| x as char )
473+ . collect ( )
460474}
0 commit comments