Compare commits
3 commits
4f3229e436
...
242982ff0b
Author | SHA1 | Date | |
---|---|---|---|
|
242982ff0b | ||
|
9d99c2a9c8 | ||
|
a9f7dad63e |
3 changed files with 7 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
namespace Uwaa.HTTP;
|
namespace Uwaa.HTTP;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// General purpose implementation of <see cref="IHttpFields"/>.
|
/// Fields of a HTTP request/response header.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record HttpFields
|
public record HttpFields
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class StaticEndpoint : RouterBase
|
||||||
Response = response;
|
Response = response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override HttpMethod Method => HttpMethod.GET;
|
public override HttpMethod Method => HttpMethod.Any;
|
||||||
|
|
||||||
public override int Arguments => 0;
|
public override int Arguments => 0;
|
||||||
|
|
||||||
|
|
|
@ -669,7 +669,11 @@ public class Pleroma
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<Stream> DownloadStream(Attachment attachment)
|
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();
|
res.EnsureSuccessStatusCode();
|
||||||
return await res.Content.ReadAsStreamAsync();
|
return await res.Content.ReadAsStreamAsync();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue