pleroma: do not auth remote media

This commit is contained in:
uwaa 2025-01-19 01:27:00 +00:00
parent 9d99c2a9c8
commit 242982ff0b

View file

@ -669,7 +669,11 @@ public class Pleroma
/// </summary>
public async Task<Stream> DownloadStream(Attachment attachment)
{
HttpResponseMessage res = await HttpClient.GetAsync(attachment.URL);
using HttpClient client = new HttpClient();
if (HttpClient.BaseAddress != null && new Uri(attachment.URL).Host == HttpClient.BaseAddress.Host)
client.DefaultRequestHeaders.Authorization = HttpClient.DefaultRequestHeaders.Authorization;
HttpResponseMessage res = await client.GetAsync(attachment.URL);
res.EnsureSuccessStatusCode();
return await res.Content.ReadAsStreamAsync();
}