Refactoring XmlRpc serialization to use XmlWriterSettings

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-10-07 08:51:44 -07:00
parent eb48cafba5
commit c8a6517aa8

View File

@@ -3,6 +3,7 @@ using System.IO;
using System.Text; using System.Text;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using Orchard.Core.XmlRpc.Models; using Orchard.Core.XmlRpc.Models;
using Orchard.Core.XmlRpc.Services; using Orchard.Core.XmlRpc.Services;
@@ -38,18 +39,15 @@ namespace Orchard.Core.XmlRpc.Controllers {
if (methodResponse == null) if (methodResponse == null)
throw new HttpException(500, "TODO: xmlrpc fault"); throw new HttpException(500, "TODO: xmlrpc fault");
var result = _writer.MapMethodResponse(methodResponse);
return Content(result.ToString(), "text/xml"); var sb = new StringBuilder();
} var settings = new XmlWriterSettings {Encoding = Encoding.UTF8};
[HttpHead, ActionName("Index")] using (XmlWriter w = XmlWriter.Create(sb, settings)) {
[AlwaysAccessible] var result = _writer.MapMethodResponse(methodResponse);
public ActionResult ExistenceDiscovery() { result.Save(w);
//see http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/office-existence-discovery-protocol.aspx return Content(result.ToString(), "text/xml");
Logger.Debug("Microsoft Office Existence Discovery"); }
Response.AddHeader("Last-Modified", _clock.UtcNow.ToString("o"));
return Content("", "text/xml");
} }
private XRpcMethodResponse Dispatch(XRpcMethodCall request) { private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
@@ -68,4 +66,5 @@ namespace Orchard.Core.XmlRpc.Controllers {
return context.Response; return context.Response;
} }
} }
} }