public Task WriteContentTo(Environment environment) { var context = (environment["System.Net.HttpListenerContext"] as System.Net.HttpListenerContext); context.Response.SendChunked = false; context.Response.ContentLength64 = 0; context.Response.StatusCode = statusCode; environment.ResponseStatusCode = statusCode; return(done); }
public Task WriteContentTo(Environment environment) { var context = (environment["System.Net.HttpListenerContext"] as System.Net.HttpListenerContext); context.Response.SendChunked = false; context.Response.ContentLength64 = content.Headers.ContentLength ?? 0; context.Response.ContentEncoding = Encoding.UTF8; context.Response.StatusCode = statusCode; environment.ResponseStatusCode = statusCode; return(content.CopyToAsync(environment.ResponseBody)); }
public async Task <MiddlewareInvocationEnum> Invoke(Environment environment) { var request = await Request.FromEnvironment(environment); if (!CanHandleRequest(request)) { return(MiddlewareInvocationEnum.ContinueToNext); } await ControllerFunction(request).WriteContentTo(environment); return(MiddlewareInvocationEnum.StopChain); }
public async Task WriteContentTo(Environment environment) { var serialized = JsonConvert.SerializeObject(@return); var bytes = Encoding.UTF8.GetBytes(serialized); var context = (environment["System.Net.HttpListenerContext"] as System.Net.HttpListenerContext); context.Response.SendChunked = false; context.Response.ContentLength64 = bytes.LongLength; context.Response.ContentEncoding = Encoding.UTF8; context.Response.StatusCode = statusCode; environment.ResponseStatusCode = statusCode; await environment.ResponseBody.WriteAsync(bytes, 0, bytes.Length); }
public async Task <MiddlewareInvocationEnum> Invoke(Environment environment) { if (environment.RequestHeaders.TryGetValue(SET_REPLY_HEADER_NAME, out string[] setReplyHeader) &&