Added content type and WriteAsync as a stop gap.
This commit is contained in:
parent
76ef358974
commit
336e69a677
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNet.Abstractions
|
||||
{
|
||||
|
|
@ -9,5 +10,9 @@ namespace Microsoft.AspNet.Abstractions
|
|||
public abstract HttpContext HttpContext { get; }
|
||||
public abstract int StatusCode { get; set; }
|
||||
public abstract Stream Body { get; set; }
|
||||
|
||||
public abstract string ContentType { get; set; }
|
||||
|
||||
public abstract Task WriteAsync(string data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.HttpFeature;
|
||||
using Microsoft.AspNet.HttpFeature.Security;
|
||||
|
|
@ -28,7 +30,7 @@ namespace Microsoft.AspNet.PipelineCore
|
|||
_response = null;
|
||||
_revision = _context.Revision;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override HttpContext HttpContext { get { return _context; } }
|
||||
|
||||
|
|
@ -39,5 +41,24 @@ namespace Microsoft.AspNet.PipelineCore
|
|||
}
|
||||
|
||||
public override Stream Body { get { return _response.Body; } set { _response.Body = value; } }
|
||||
|
||||
public override string ContentType
|
||||
{
|
||||
get
|
||||
{
|
||||
var contentTypeValues = IHttpResponse.Headers["Content-Type"];
|
||||
return contentTypeValues.Length == 0 ? null : contentTypeValues[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
IHttpResponse.Headers["Content-Type"] = new[] { value };
|
||||
}
|
||||
}
|
||||
|
||||
public override Task WriteAsync(string data)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(data);
|
||||
return Body.WriteAsync(bytes, 0, bytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue