aboutsummaryrefslogtreecommitdiff
path: root/ServiceStack/Host/ContentTypes.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ServiceStack/Host/ContentTypes.cs')
-rw-r--r--ServiceStack/Host/ContentTypes.cs22
1 files changed, 4 insertions, 18 deletions
diff --git a/ServiceStack/Host/ContentTypes.cs b/ServiceStack/Host/ContentTypes.cs
index 22fdc3e50..f7734a36b 100644
--- a/ServiceStack/Host/ContentTypes.cs
+++ b/ServiceStack/Host/ContentTypes.cs
@@ -13,37 +13,23 @@ 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 httpRes = new HttpResponseStreamWrapper(responseStream, req)
- {
- Dto = req.Response.Dto
- };
- serializer(req, response, httpRes);
- }
-
- public Action<IRequest, object, IResponse> GetResponseSerializer(string contentType)
- {
var serializer = GetStreamSerializer(contentType);
- if (serializer == null) return null;
- return (httpReq, dto, httpRes) => serializer(httpReq, dto, httpRes.OutputStream);
+ serializer(response, responseStream);
}
- public Action<IRequest, object, Stream> GetStreamSerializer(string contentType)
+ public static 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;