diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-11-12 02:49:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-12 02:49:33 -0500 |
| commit | d5197eabb0b2ac375cd7610aa7cc4a7e61a88245 (patch) | |
| tree | 0f05bf569a19c75b9654af69d8356c67ff0c2de0 /ServiceStack/Host/ContentTypes.cs | |
| parent | 67b69ceb9418ef530296238d1776894b675f4c5e (diff) | |
| parent | 6865bb53530abbf703b590dd39cfa27274b03107 (diff) | |
Merge pull request #2283 from MediaBrowser/dev
Dev
Diffstat (limited to 'ServiceStack/Host/ContentTypes.cs')
| -rw-r--r-- | ServiceStack/Host/ContentTypes.cs | 22 |
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; |
