optimization request http

This commit is contained in:
Aigio Liu
2021-03-03 23:57:53 +08:00
parent 4024236000
commit ef8afedab1
18 changed files with 541 additions and 152 deletions
@@ -2,13 +2,16 @@
namespace System.Net.Http
{
public abstract class HttpService
/// <summary>
/// 通用 <see cref="HttpClient"/> 工厂
/// </summary>
public abstract class GeneralHttpClientFactory
{
protected readonly ILogger logger;
protected readonly IHttpPlatformHelper http_helper;
readonly IHttpClientFactory _clientFactory;
public HttpService(
public GeneralHttpClientFactory(
ILogger logger,
IHttpPlatformHelper http_helper,
IHttpClientFactory clientFactory)
@@ -1,4 +1,5 @@
using System.IO;
using System.IO.FileFormats;
namespace System.Net.Http
{
@@ -9,6 +10,17 @@ namespace System.Net.Http
public virtual string UserAgent => DefaultUserAgent;
public virtual string AcceptImages => "image/png, image/*; q=0.8";
static readonly Lazy<ImageFormat[]> mSupportedImageFormats = new(() => new ImageFormat[]
{
ImageFormat.JPEG,
ImageFormat.PNG,
ImageFormat.GIF,
});
public virtual ImageFormat[] SupportedImageFormats => mSupportedImageFormats.Value;
public (string filePath, string mime)? TryHandleUploadFile(Stream fileStream) => null;
}
}
@@ -1,4 +1,5 @@
using System.IO;
using System.IO.FileFormats;
namespace System.Net.Http
{
@@ -14,6 +15,9 @@ namespace System.Net.Http
/// </summary>
string UserAgent { get; }
string AcceptImages { get; }
ImageFormat[] SupportedImageFormats { get; }
/// <summary>
/// 尝试将需要上传的文件流[处理]后保存到临时路径中并返回信息
/// <para>[处理]由客户端平台原生实现</para>