|
|
@@ -1,3 +1,5 @@
|
|
|
+using System.Buffers;
|
|
|
+using System.IO.Pipelines;
|
|
|
using System.Text;
|
|
|
using TouchSocket.Core;
|
|
|
using TouchSocket.Http;
|
|
|
@@ -10,7 +12,7 @@ public class Program
|
|
|
private static async Task Main(string[] args)
|
|
|
{
|
|
|
int port = 8080;
|
|
|
- var service = new MyHttpService();
|
|
|
+ MyHttpService service = new MyHttpService();
|
|
|
|
|
|
await service.SetupAsync(new TouchSocketConfig()
|
|
|
.SetListenIPHosts(port)
|
|
|
@@ -18,6 +20,24 @@ public class Program
|
|
|
.SetTransportOption(options =>
|
|
|
{
|
|
|
options.BufferOnDemand = false;
|
|
|
+
|
|
|
+ options.ReceivePipeOptions = new PipeOptions(
|
|
|
+ pool: MemoryPool<byte>.Shared,
|
|
|
+ readerScheduler: PipeScheduler.ThreadPool,
|
|
|
+ writerScheduler: PipeScheduler.ThreadPool,
|
|
|
+ pauseWriterThreshold: 1024 * 1024,
|
|
|
+ resumeWriterThreshold: 1024 * 512,
|
|
|
+ minimumSegmentSize: -1,
|
|
|
+ useSynchronizationContext: false);
|
|
|
+
|
|
|
+ options.SendPipeOptions = new PipeOptions(
|
|
|
+ pool: MemoryPool<byte>.Shared,
|
|
|
+ readerScheduler: PipeScheduler.ThreadPool,
|
|
|
+ writerScheduler: PipeScheduler.ThreadPool,
|
|
|
+ pauseWriterThreshold: 64 * 1024,
|
|
|
+ resumeWriterThreshold: 32 * 1024,
|
|
|
+ minimumSegmentSize: -1,
|
|
|
+ useSynchronizationContext: false);
|
|
|
})
|
|
|
.ConfigureContainer(a =>
|
|
|
{
|
|
|
@@ -48,8 +68,8 @@ internal sealed class MyHttpSessionClient : HttpSessionClient
|
|
|
|
|
|
protected override async Task OnReceivedHttpRequest(HttpContext httpContext)
|
|
|
{
|
|
|
- var request = httpContext.Request;
|
|
|
- var response = httpContext.Response;
|
|
|
+ HttpRequest request = httpContext.Request;
|
|
|
+ HttpResponse response = httpContext.Response;
|
|
|
|
|
|
switch (request.RelativeURL)
|
|
|
{
|