#134 - Add HeadersSent api.
This commit is contained in:
parent
b9b172c2e0
commit
389e27e460
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http.Security;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
|
|
@ -24,6 +23,8 @@ namespace Microsoft.AspNet.Http
|
|||
|
||||
public abstract IResponseCookies Cookies { get; }
|
||||
|
||||
public abstract bool HeadersSent { get; }
|
||||
|
||||
public abstract void OnSendingHeaders(Action<object> callback, object state);
|
||||
|
||||
public virtual void Redirect(string location)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace Microsoft.AspNet.HttpFeature
|
|||
string ReasonPhrase { get; set; }
|
||||
IDictionary<string, string[]> Headers { get; set; }
|
||||
Stream Body { get; set; }
|
||||
bool HeadersSent { get; }
|
||||
void OnSendingHeaders(Action<object> callback, object state);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,22 @@ namespace Microsoft.AspNet.Owin
|
|||
IOwinEnvironmentFeature
|
||||
{
|
||||
public IDictionary<string, object> Environment { get; set; }
|
||||
private bool _headersSent;
|
||||
|
||||
public OwinFeatureCollection(IDictionary<string, object> environment)
|
||||
{
|
||||
Environment = environment;
|
||||
SupportsWebSockets = true;
|
||||
|
||||
var register = Prop<Action<Action<object>, object>>(OwinConstants.CommonKeys.OnSendingHeaders);
|
||||
if (register != null)
|
||||
{
|
||||
register(state =>
|
||||
{
|
||||
var collection = (OwinFeatureCollection)state;
|
||||
collection._headersSent = true;
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
T Prop<T>(string key)
|
||||
|
|
@ -129,6 +140,11 @@ namespace Microsoft.AspNet.Owin
|
|||
set { Prop(OwinConstants.ResponseBody, value); }
|
||||
}
|
||||
|
||||
bool IHttpResponseFeature.HeadersSent
|
||||
{
|
||||
get { return _headersSent; }
|
||||
}
|
||||
|
||||
void IHttpResponseFeature.OnSendingHeaders(Action<object> callback, object state)
|
||||
{
|
||||
var register = Prop<Action<Action<object>, object>>(OwinConstants.CommonKeys.OnSendingHeaders);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ namespace Microsoft.AspNet.PipelineCore
|
|||
get { return ResponseCookiesFeature.Cookies; }
|
||||
}
|
||||
|
||||
public override bool HeadersSent
|
||||
{
|
||||
get { return HttpResponseFeature.HeadersSent; }
|
||||
}
|
||||
|
||||
public override void OnSendingHeaders(Action<object> callback, object state)
|
||||
{
|
||||
HttpResponseFeature.OnSendingHeaders(callback, state);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@ namespace Microsoft.AspNet.PipelineCore
|
|||
|
||||
public Stream Body { get; set; }
|
||||
|
||||
public bool HeadersSent
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public void OnSendingHeaders(Action<object> callback, object state)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
|
|
|
|||
Loading…
Reference in New Issue