http-headers - 检查 SignalR 集线器中的可选 header

标签 http-headers signalr signalr-hub

在 SignalR 集线器方法中,Context.Headers 提供带有请求 header 的 INameValueCollectionINameValueCollection 只有三个成员:

    string this[string key] { get; }
    string Get(string key);
    IEnumerable<string> GetValues(string key);

不幸的是,这些都没有被记录下来。如果你想获取一个 header ,但如果它不存在则不抛出异常,你会使用什么?我猜是 Get,但如果作者能费心记录这些细节,那就太好了。

我喜欢“老”微软的一件事是,即使有点冗长,它的文档几乎涵盖了所有语义。 SignalR 是一个美妙、快速的开发,但如果它保留了老式的勤奋那就更好了。

也许我错过了一些东西。语义是否记录在某处?或者是否有人知道并愿意将它们记录在这里作为一种快速而肮脏的解决方法?

最佳答案

遇到了同样的问题,最后我在 the github source 中查找了它这会带你System.Collections.Specialized.NameValueCollection

(还有 INameValueCollection 的其他实现,但链接的实现似乎在请求中使用)

简而言之:

string this[string key] { get; }
string Get(string key);

A String that contains the comma-separated list of values associated with the specified key, if found; otherwise, null.

IEnumerable<string> GetValues(string key);

A String array that contains the values associated with the specified key from the NameValueCollection, if found; otherwise, null.

关于http-headers - 检查 SignalR 集线器中的可选 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31492986/

相关文章:

javascript - 尝试从 Firefox 读取实时 HTTP header 报告

java - 使用 Java URLConnection 关闭 Cookie

javascript - SignalR + AG-Grid AngularJS gridoption api 未定义

javascript - 如何使用 SignalR 向特定客户端发送消息

asp.net - SignalR 集线器(在云中)从服务器到客户端方法回调的间歇性问题

ruby-on-rails - 在 Rails/Rack 中禁用 Content-Type header

php - 带有 json 响应的 Symfony 操作

javascript - 如何在 signalR 中实现 "on"方法?

.net - Signalr:通过wpf连接远程主机

c# - Signalr 不发送给特定用户