Compare commits

...

3 commits

Author SHA1 Message Date
uwaa
242982ff0b pleroma: do not auth remote media 2025-01-19 01:27:00 +00:00
uwaa
9d99c2a9c8 http: allow Any method on static endpoint 2025-01-19 01:26:42 +00:00
uwaa
a9f7dad63e http: httpfields docs 2025-01-19 01:26:22 +00:00
3 changed files with 7 additions and 3 deletions

View file

@ -1,7 +1,7 @@
namespace Uwaa.HTTP;
/// <summary>
/// General purpose implementation of <see cref="IHttpFields"/>.
/// Fields of a HTTP request/response header.
/// </summary>
public record HttpFields
{

View file

@ -9,7 +9,7 @@ public class StaticEndpoint : RouterBase
Response = response;
}
public override HttpMethod Method => HttpMethod.GET;
public override HttpMethod Method => HttpMethod.Any;
public override int Arguments => 0;

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();
}