Skip to content

Commit d695bd2

Browse files
committed
fix: use MEDIA_CLIENT for GitHub fetches
1 parent 79580b2 commit d695bd2

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

src/main.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::sync::LazyLock;
99
use futures_lite::FutureExt;
1010
use hyper::{header::HeaderValue, Body, Request, Response};
1111
use log::{info, warn};
12-
use redlib::client::{canonical_path, proxy, rate_limit_check, CLIENT};
12+
use redlib::client::{canonical_path, proxy, rate_limit_check, MEDIA_CLIENT};
1313
use redlib::server::{self, RequestExt};
1414
use redlib::utils::{error, redirect, ThemeAssets};
1515
use redlib::{config, duplicates, headers, instance_info, post, search, settings, subreddit, user};
@@ -436,18 +436,15 @@ pub async fn proxy_commit_info() -> Result<Response<Body>, String> {
436436
#[cached(time = 600)]
437437
async fn fetch_commit_info() -> String {
438438
// wreq uses http v1.x: pass URL as &str and call .send().await, then .bytes().await
439-
CLIENT
439+
let bytes = MEDIA_CLIENT
440440
.get("https://github.com/redlib-org/redlib/commits/main.atom")
441441
.send()
442442
.await
443443
.expect("Failed to request GitHub")
444444
.bytes()
445445
.await
446-
.expect("Failed to read body")
447-
.iter()
448-
.copied()
449-
.map(|x| x as char)
450-
.collect()
446+
.expect("Failed to read body");
447+
String::from_utf8_lossy(&bytes).into_owned()
451448
}
452449

453450
pub async fn proxy_instances() -> Result<Response<Body>, String> {
@@ -463,16 +460,13 @@ pub async fn proxy_instances() -> Result<Response<Body>, String> {
463460
#[cached(time = 600)]
464461
async fn fetch_instances() -> String {
465462
// wreq uses http v1.x: pass URL as &str and call .send().await, then .bytes().await
466-
CLIENT
463+
let bytes = MEDIA_CLIENT
467464
.get("https://raw.githubusercontent.com/redlib-org/redlib-instances/refs/heads/main/instances.json")
468465
.send()
469466
.await
470467
.expect("Failed to request GitHub")
471468
.bytes()
472469
.await
473-
.expect("Failed to read body")
474-
.iter()
475-
.copied()
476-
.map(|x| x as char)
477-
.collect()
470+
.expect("Failed to read body");
471+
String::from_utf8_lossy(&bytes).into_owned()
478472
}

0 commit comments

Comments
 (0)