mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-28 17:32:44 +08:00
Passing the HttpContextBase along with XmlRpcContext to enable handlers to determine http url
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4039508
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using Orchard.CmsPages.ViewModels;
|
||||
using Orchard.Logging;
|
||||
using Orchard.XmlRpc;
|
||||
@@ -20,12 +21,16 @@ namespace Orchard.CmsPages.Services {
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public void Process(XmlRpcContext context) {
|
||||
var uriBuilder = new UriBuilder(context.HttpContext.Request.Url);
|
||||
uriBuilder.Path = context.HttpContext.Request.ApplicationPath;
|
||||
uriBuilder.Query = string.Empty;
|
||||
|
||||
|
||||
if (context.Request.MethodName == "blogger.getUsersBlogs") {
|
||||
context.Response = new XRpcMethodResponse()
|
||||
.Add(new XRpcArray()
|
||||
.Add(new XRpcStruct()
|
||||
.Set("url", "http://localhost:40245/")
|
||||
.Set("url", uriBuilder.Uri.AbsoluteUri)
|
||||
.Set("blogid", "Orchard.CmsPages")
|
||||
.Set("blogName", "Orchard Pages")));
|
||||
}
|
||||
@@ -61,6 +66,7 @@ namespace Orchard.CmsPages.Services {
|
||||
|
||||
if (context.Request.MethodName == "metaWeblog.newMediaObject") {
|
||||
var result = MetaWeblogNewMediaObject(
|
||||
uriBuilder,
|
||||
Convert.ToString(context.Request.Params[0].Value),
|
||||
Convert.ToString(context.Request.Params[1].Value),
|
||||
Convert.ToString(context.Request.Params[2].Value),
|
||||
@@ -140,6 +146,7 @@ namespace Orchard.CmsPages.Services {
|
||||
}
|
||||
|
||||
private XRpcStruct MetaWeblogNewMediaObject(
|
||||
UriBuilder uriBuilder,
|
||||
string blogId,
|
||||
string user,
|
||||
string password,
|
||||
@@ -153,7 +160,8 @@ namespace Orchard.CmsPages.Services {
|
||||
stream.Write(bits, 0, bits.Length);
|
||||
}
|
||||
|
||||
return new XRpcStruct().Set("url", "http://localhost:40245/Files/" + name);
|
||||
uriBuilder.Path = uriBuilder.Path.TrimEnd('/') + "/Files/" + name.TrimStart('/');
|
||||
return new XRpcStruct().Set("url", uriBuilder.Uri.AbsoluteUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Orchard.XmlRpc.Controllers {
|
||||
}
|
||||
|
||||
private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
|
||||
var context = new XmlRpcContext { Request = request };
|
||||
var context = new XmlRpcContext { HttpContext = HttpContext, Request = request };
|
||||
foreach (var handler in _xmlRpcHandlers)
|
||||
handler.Process(context);
|
||||
return context.Response;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Web;
|
||||
using Orchard.XmlRpc.Models;
|
||||
|
||||
namespace Orchard.XmlRpc {
|
||||
public class XmlRpcContext {
|
||||
public HttpContextBase HttpContext { get; set; }
|
||||
public XRpcMethodCall Request { get; set; }
|
||||
public XRpcMethodResponse Response { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user