Task SendResponse(MHttpResponse response, string html, MHttpStream local) { html = m_info.ReplaceResponseHtml(html); response.Headers.RemoveHopByHopHeaders(); response.SetContent(html); return(response.SendAsync(local)); }
static void ReadConnectRequest(Socket socket, Func <string, TunnelPackAction> func) { Task.Run(async() => { Stream stream = new NetworkStream(socket, true); MHttpStream httpStream = new MHttpStream(socket, stream, 1024); MHttpRequest request = await MHttpRequest.ReadAsync(httpStream, 1024 * 1024).ConfigureAwait(false); MHttpResponse response = MHttpResponse.Create(200); await response.SendAsync(httpStream).ConfigureAwait(false); Uri uri = new Uri($"http://{request.Path}/"); func(uri.Host)(uri, new TunnelPack(socket, stream)); }); }