【问题标题】:Consuming a stream in the context of a Servicestack client在 Servicestack 客户端的上下文中使用流
【发布时间】:2013-03-15 05:33:12
【问题描述】:

虽然我已经了解了如何easily write to the response stream,但我想知道在 ServiceStack 客户端的上下文中(例如ServiceClientBase)我是否可以访问服务器的响应流。

在我开始访问 HttpWebResponse 对象之前,我想再次确认我没有重新发明轮子。

【问题讨论】:

    标签: .net-4.0 servicestack httpwebresponse


    【解决方案1】:

    有关如何访问underlying raw response types 的示例,请参阅这个较早的答案。

    另外,C# ServiceClient wiki 是 ServiceStack 内置 C#/.NET 服务客户端的权威文档。它包括一个关于accessing the underlying raw response 不同方式的部分,包括通过响应流:

    using (Stream responseStream = client.Get<Stream>("/poco/World")) {
        var dto = responseStream.ReadFully().FromUtf8Bytes().FromJson<PocoResponse>();
        dto.Result //Hello, World
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-28
      • 1970-01-01
      相关资源
      最近更新 更多