public Task Invoke(IDictionary<string, object> env) { Stream orriginalStream = env.Get<Stream>(OwinConstants.ResponseBody); TriggerStream triggerStream = new TriggerStream(orriginalStream); env[OwinConstants.ResponseBody] = triggerStream; triggerStream.OnFirstWrite = () => { var responseHeaders = env.Get<IDictionary<string, string[]>>(OwinConstants.ResponseHeaders); if (!responseHeaders.HasHeader("Content-Type")) { responseHeaders.SetHeader("Content-Type", contentType); } }; return nextApp(env).Then(() => { // Make sure this gets run even if there were no writes. triggerStream.OnFirstWrite(); }); }
public Task Invoke(IDictionary <string, object> env) { Stream orriginalStream = env.Get <Stream>(OwinConstants.ResponseBody); TriggerStream triggerStream = new TriggerStream(orriginalStream); env[OwinConstants.ResponseBody] = triggerStream; triggerStream.OnFirstWrite = () => { var responseHeaders = env.Get <IDictionary <string, string[]> >(OwinConstants.ResponseHeaders); if (!responseHeaders.HasHeader("Content-Type")) { responseHeaders.SetHeader("Content-Type", contentType); } }; return(nextApp(env).Then(() => { // Make sure this gets run even if there were no writes. triggerStream.OnFirstWrite(); })); }
public Task Invoke(IDictionary<string, object> env) { var resp = new Response(env); Stream orriginalStream = resp.Body; TriggerStream triggerStream = new TriggerStream(orriginalStream); resp.Body = triggerStream; triggerStream.OnFirstWrite = () => { var responseHeaders = resp.Headers; if (!responseHeaders.HasHeader("Content-Type")) { responseHeaders.SetHeader("Content-Type", contentType); } }; return nextApp(env).Then(() => { // Make sure this gets run even if there were no writes. triggerStream.OnFirstWrite(); }); }
public Task Invoke(IDictionary <string, object> env) { var resp = new Response(env); Stream orriginalStream = resp.Body; TriggerStream triggerStream = new TriggerStream(orriginalStream); resp.Body = triggerStream; triggerStream.OnFirstWrite = () => { var responseHeaders = resp.Headers; if (!responseHeaders.HasHeader("Content-Type")) { responseHeaders.SetHeader("Content-Type", contentType); } }; return(nextApp(env).Then(() => { // Make sure this gets run even if there were no writes. triggerStream.OnFirstWrite(); })); }