1234567891011121314151617181920212223 |
- using System.IO;
- using System.Net;
- using System.Text;
- namespace ET.Server
- {
- public static class HttpHelper
- {
- public static async ETTask<string> GetBodyParameter(HttpListenerContext context)
- {
- return await new StreamReader(context.Request.InputStream).ReadToEndAsync();
- }
- public static void Response(HttpListenerContext context, object response)
- {
- byte[] bytes = JsonHelper.ToJson(response).ToUtf8();
- context.Response.StatusCode = 200;
- context.Response.ContentEncoding = Encoding.UTF8;
- context.Response.ContentLength64 = bytes.Length;
- context.Response.OutputStream.Write(bytes, 0, bytes.Length);
- }
- }
- }
|