ServiceStack HEAD请求,查询参数不起作用

时间:2014-04-21 13:26:07

标签: servicestack

我尝试在ServiceStack中使用名为EMail的查询参数实现HEAD请求。 ServiceStack客户端似乎将查询参数编码为错误,因为它与另一个REST客户端(例如Dev HTTP Client)正常工作。我尝试了Xml和Json服务客户端。

示例代码:

using System;
using System.Diagnostics;
using Funq;
using ServiceStack;

namespace ServiceStackHead
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var appHost = new AppHost();
            appHost.Init();
            appHost.Start("http://localhost:1337/");

            var client = new JsonServiceClient("http://localhost:1337");
            client.Head(new SampleHeadRequest { EMail = "test@blub.com" });
        }
    }

    public class AppHost : AppHostHttpListenerBase
    {
        public AppHost()
            : base("ServiceStack HEAD Test", typeof(AppHost).Assembly)
        {
        }

        public override void Configure(Container container)
        {
        }
    }

    [Route("/sample", "HEAD")]
    public class SampleHeadRequest : IReturnVoid
    {
        public string EMail { get; set; }
    }

    public class SampleService : Service
    {
        public object Head(SampleHeadRequest request)
        {
            Console.WriteLine("EMail: " + request.EMail);

            // EMail is not properly set here
            Debugger.Break();

            return null;
        }
    }
}

您还可以从https://github.com/olibanjoli/ServiceStackHead

克隆代码

0 个答案:

没有答案