From d346890b1f3eda453833ceba67f4c685e4f6e162 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Tue, 17 Dec 2024 15:01:53 +0000 Subject: [PATCH] Increase metadata fetch limit to 1 MB (fixes #5208) (#5266) --- crates/api_common/src/request.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index c6f86b806..02e889872 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -51,9 +51,11 @@ pub fn client_builder(settings: &Settings) -> ClientBuilder { #[tracing::instrument(skip_all)] pub async fn fetch_link_metadata(url: &Url, context: &LemmyContext) -> LemmyResult { info!("Fetching site metadata for url: {}", url); - // We only fetch the first 64kB of data in order to not waste bandwidth especially for large - // binary files - let bytes_to_fetch = 64 * 1024; + // We only fetch the first MB of data in order to not waste bandwidth especially for large + // binary files. This high limit is particularly needed for youtube, which includes a lot of + // javascript code before the opengraph tags. Mastodon also uses a 1 MB limit: + // https://github.com/mastodon/mastodon/blob/295ad6f19a016b3f16e1201ffcbb1b3ad6b455a2/app/lib/request.rb#L213 + let bytes_to_fetch = 1024 * 1024; let response = context .client() .get(url.as_str())