Files
se-launcher/PluginLoader/Tools/PostHttpContent.cs

25 lines
623 B
C#

using System.Net;
namespace PluginLoader.Tools;
public class PostHttpContent : HttpContent
{
private readonly byte[] content;
public PostHttpContent(string content)
{
this.content = content == null ? null : Tools.Utf8.GetBytes(content);
}
protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context)
{
if (content != null && content.Length > 0)
await stream.WriteAsync(content, 0, content.Length);
}
protected override bool TryComputeLength(out long length)
{
length = content.Length;
return true;
}
}