aboutsummaryrefslogtreecommitdiff
path: root/ServiceStack/Host
diff options
context:
space:
mode:
Diffstat (limited to 'ServiceStack/Host')
-rw-r--r--ServiceStack/Host/ContentTypes.cs20
-rw-r--r--ServiceStack/Host/HttpResponseStreamWrapper.cs95
-rw-r--r--ServiceStack/Host/ServiceController.cs3
3 files changed, 7 insertions, 111 deletions
diff --git a/ServiceStack/Host/ContentTypes.cs b/ServiceStack/Host/ContentTypes.cs
index 22fdc3e50..58ba29801 100644
--- a/ServiceStack/Host/ContentTypes.cs
+++ b/ServiceStack/Host/ContentTypes.cs
@@ -13,37 +13,31 @@ namespace ServiceStack.Host
public void SerializeToStream(IRequest req, object response, Stream responseStream)
{
var contentType = req.ResponseContentType;
- var serializer = GetResponseSerializer(contentType);
- if (serializer == null)
- throw new NotSupportedException("ContentType not supported: " + contentType);
+ var serializer = GetStreamSerializer(contentType);
- var httpRes = new HttpResponseStreamWrapper(responseStream, req)
- {
- Dto = req.Response.Dto
- };
- serializer(req, response, httpRes);
+ serializer(response, responseStream);
}
- public Action<IRequest, object, IResponse> GetResponseSerializer(string contentType)
+ public Action<object, IResponse> GetResponseSerializer(string contentType)
{
var serializer = GetStreamSerializer(contentType);
if (serializer == null) return null;
- return (httpReq, dto, httpRes) => serializer(httpReq, dto, httpRes.OutputStream);
+ return (dto, httpRes) => serializer(dto, httpRes.OutputStream);
}
- public Action<IRequest, object, Stream> GetStreamSerializer(string contentType)
+ public Action<object, Stream> GetStreamSerializer(string contentType)
{
switch (GetRealContentType(contentType))
{
case "application/xml":
case "text/xml":
case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml
- return (r, o, s) => ServiceStackHost.Instance.SerializeToXml(o, s);
+ return (o, s) => ServiceStackHost.Instance.SerializeToXml(o, s);
case "application/json":
case "text/json":
- return (r, o, s) => ServiceStackHost.Instance.SerializeToJson(o, s);
+ return (o, s) => ServiceStackHost.Instance.SerializeToJson(o, s);
}
return null;
diff --git a/ServiceStack/Host/HttpResponseStreamWrapper.cs b/ServiceStack/Host/HttpResponseStreamWrapper.cs
deleted file mode 100644
index 33038da72..000000000
--- a/ServiceStack/Host/HttpResponseStreamWrapper.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Text;
-using MediaBrowser.Model.Services;
-
-namespace ServiceStack.Host
-{
- public class HttpResponseStreamWrapper : IHttpResponse
- {
- private static readonly UTF8Encoding UTF8EncodingWithoutBom = new UTF8Encoding(false);
-
- public HttpResponseStreamWrapper(Stream stream, IRequest request)
- {
- this.OutputStream = stream;
- this.Request = request;
- this.Headers = new Dictionary<string, string>();
- this.Items = new Dictionary<string, object>();
- }
-
- public Dictionary<string, string> Headers { get; set; }
-
- public object OriginalResponse
- {
- get { return null; }
- }
-
- public IRequest Request { get; private set; }
-
- public int StatusCode { set; get; }
- public string StatusDescription { set; get; }
- public string ContentType { get; set; }
-
- public void AddHeader(string name, string value)
- {
- this.Headers[name] = value;
- }
-
- public string GetHeader(string name)
- {
- return this.Headers[name];
- }
-
- public void Redirect(string url)
- {
- this.Headers["Location"] = url;
- }
-
- public Stream OutputStream { get; private set; }
-
- public object Dto { get; set; }
-
- public void Write(string text)
- {
- var bytes = UTF8EncodingWithoutBom.GetBytes(text);
- OutputStream.Write(bytes, 0, bytes.Length);
- }
-
- public bool UseBufferedStream { get; set; }
-
- public void Close()
- {
- if (IsClosed) return;
-
- OutputStream.Dispose();
- IsClosed = true;
- }
-
- public void End()
- {
- Close();
- }
-
- public void Flush()
- {
- OutputStream.Flush();
- }
-
- public bool IsClosed { get; private set; }
-
- public void SetContentLength(long contentLength) {}
-
- public bool KeepAlive { get; set; }
-
- public Dictionary<string, object> Items { get; private set; }
-
- public void SetCookie(Cookie cookie)
- {
- }
-
- public void ClearCookies()
- {
- }
- }
-} \ No newline at end of file
diff --git a/ServiceStack/Host/ServiceController.cs b/ServiceStack/Host/ServiceController.cs
index 703f06365..7eb1253b3 100644
--- a/ServiceStack/Host/ServiceController.cs
+++ b/ServiceStack/Host/ServiceController.cs
@@ -210,9 +210,6 @@ namespace ServiceStack.Host
//Executes the service and returns the result
var response = await ServiceExecGeneral.Execute(serviceType, req, service, requestDto, requestType.GetOperationName()).ConfigureAwait(false);
- if (req.Response.Dto == null)
- req.Response.Dto = response;
-
return response;
}
}