当前位置: 首页>>代码示例>>C#>>正文


C# Headers.Add方法代码示例

本文整理汇总了C#中Headers.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Headers.Add方法的具体用法?C# Headers.Add怎么用?C# Headers.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Headers的用法示例。


在下文中一共展示了Headers.Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessControlRequestInternal

        private ControlResponse ProcessControlRequestInternal(ControlRequest request)
        {
            var soap = new XmlDocument();
            soap.LoadXml(request.InputXml);
            var sparams = new Headers();
            var body = soap.GetElementsByTagName("Body", NS_SOAPENV).Item(0);

            var method = body.FirstChild;

            foreach (var p in method.ChildNodes)
            {
                var e = p as XmlElement;
                if (e == null)
                {
                    continue;
                }
                sparams.Add(e.LocalName, e.InnerText.Trim());
            }

            Logger.Debug("Received control request {0}", method.LocalName);

            var result = GetResult(method.LocalName, sparams);

            var env = new XmlDocument();
            env.AppendChild(env.CreateXmlDeclaration("1.0", "utf-8", string.Empty));
            var envelope = env.CreateElement("SOAP-ENV", "Envelope", NS_SOAPENV);
            env.AppendChild(envelope);
            envelope.SetAttribute("encodingStyle", NS_SOAPENV, "http://schemas.xmlsoap.org/soap/encoding/");

            var rbody = env.CreateElement("SOAP-ENV:Body", NS_SOAPENV);
            env.DocumentElement.AppendChild(rbody);

            var response = env.CreateElement(String.Format("u:{0}Response", method.LocalName), method.NamespaceURI);
            rbody.AppendChild(response);

            foreach (var i in result)
            {
                var ri = env.CreateElement(i.Key);
                ri.InnerText = i.Value;
                response.AppendChild(ri);
            }

            var xml = env.OuterXml.Replace("xmlns:m=", "xmlns:u=");
            
            var controlResponse = new ControlResponse
            {
                Xml = xml,
                IsSuccessful = true
            };

            //Logger.Debug(xml);

            controlResponse.Headers.Add("EXT", string.Empty);

            return controlResponse;
        }
开发者ID:paul-777,项目名称:Emby,代码行数:56,代码来源:BaseControlHandler.cs

示例2: CollectHeaders

 public static void CollectHeaders(Stream inputStream, Headers headers)
 {
     while (true) {
         // Collect Headers
         string[] parts = ReadKeyValue (inputStream);
         if (parts == null) {
             break;
         }
         headers.Add (parts [0], parts [1]);
     }
 }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:11,代码来源:Protocol.cs

示例3: ReadHeaders

        public static Headers ReadHeaders(Stream stream)
        {
            HeaderFields field;
            var fields = new Headers();
            var reader = new BinaryReader(stream);

            do
            {
                field = (HeaderFields)reader.ReadByte();
                var size = reader.ReadInt16();
                fields.Add(field, reader.ReadBytes(size));
            } while (field != HeaderFields.EndOfHeader);

            return fields;
        }
开发者ID:oldlaurel,项目名称:WinPass,代码行数:15,代码来源:FileFormat.cs

示例4: HandleGetSystemUpdateID

 private IEnumerable<KeyValuePair<string, string>> HandleGetSystemUpdateID()
 {
     var headers = new Headers(true);
     headers.Add("Id", _systemUpdateId.ToString(_usCulture));
     return headers;
 }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:6,代码来源:ControlHandler.cs

示例5: ProcessControlRequestInternal

        private ControlResponse ProcessControlRequestInternal(ControlRequest request)
        {
            var soap = new XmlDocument();
            soap.LoadXml(request.InputXml);
            var sparams = new Headers();
            var body = soap.GetElementsByTagName("Body", NS_SOAPENV).Item(0);

            var method = body.FirstChild;

            foreach (var p in method.ChildNodes)
            {
                var e = p as XmlElement;
                if (e == null)
                {
                    continue;
                }
                sparams.Add(e.LocalName, e.InnerText.Trim());
            }

            var deviceId = "fgd";

            var env = new XmlDocument();
            env.AppendChild(env.CreateXmlDeclaration("1.0", "utf-8", "yes"));
            var envelope = env.CreateElement("SOAP-ENV", "Envelope", NS_SOAPENV);
            env.AppendChild(envelope);
            envelope.SetAttribute("encodingStyle", NS_SOAPENV, "http://schemas.xmlsoap.org/soap/encoding/");

            var rbody = env.CreateElement("SOAP-ENV:Body", NS_SOAPENV);
            env.DocumentElement.AppendChild(rbody);

            IEnumerable<KeyValuePair<string, string>> result;

            _logger.Debug("Received control request {0}", method.Name);

            var user = _user;

            if (string.Equals(method.LocalName, "GetSearchCapabilities", StringComparison.OrdinalIgnoreCase))
                result = HandleGetSearchCapabilities();
            else if (string.Equals(method.LocalName, "GetSortCapabilities", StringComparison.OrdinalIgnoreCase))
                result = HandleGetSortCapabilities();
            else if (string.Equals(method.LocalName, "GetSystemUpdateID", StringComparison.OrdinalIgnoreCase))
                result = HandleGetSystemUpdateID();
            else if (string.Equals(method.LocalName, "Browse", StringComparison.OrdinalIgnoreCase))
                result = HandleBrowse(sparams, user, deviceId);
            else if (string.Equals(method.LocalName, "X_GetFeatureList", StringComparison.OrdinalIgnoreCase))
                result = HandleXGetFeatureList();
            else if (string.Equals(method.LocalName, "X_SetBookmark", StringComparison.OrdinalIgnoreCase))
                result = HandleXSetBookmark(sparams, user);
            else if (string.Equals(method.LocalName, "Search", StringComparison.OrdinalIgnoreCase))
                result = HandleSearch(sparams, user, deviceId);
            else
                throw new ResourceNotFoundException("Unexpected control request name: " + method.LocalName);

            var response = env.CreateElement(String.Format("u:{0}Response", method.LocalName), method.NamespaceURI);
            rbody.AppendChild(response);

            foreach (var i in result)
            {
                var ri = env.CreateElement(i.Key);
                ri.InnerText = i.Value;
                response.AppendChild(ri);
            }

            var controlResponse = new ControlResponse
            {
                Xml = env.OuterXml,
                IsSuccessful = true
            };

            controlResponse.Headers.Add("EXT", string.Empty);

            return controlResponse;
        }
开发者ID:Nickolin,项目名称:MediaBrowser,代码行数:73,代码来源:ControlHandler.cs

示例6: NotifyDevice

        private void NotifyDevice(UpnpDevice dev, string type, bool sticky)
        {
            _logger.Debug("NotifyDevice");
            var headers = new Headers(true);
            headers.Add("HOST", "239.255.255.250:1900");
            headers.Add("CACHE-CONTROL", "max-age = 600");
            headers.Add("LOCATION", dev.Descriptor.ToString());
            headers.Add("SERVER", _serverSignature);
            headers.Add("NTS", "ssdp:" + type);
            headers.Add("NT", dev.Type);
            headers.Add("USN", dev.USN);

            SendDatagram(_ssdpEndp, String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock), sticky);
            _logger.Debug("{0} said {1}", dev.USN, type);
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:15,代码来源:SsdpHandler.cs

示例7: SendSearchResponse

        private void SendSearchResponse(IPEndPoint endpoint, UpnpDevice dev)
        {
            var headers = new Headers(true);
            headers.Add("CACHE-CONTROL", "max-age = 600");
            headers.Add("DATE", DateTime.Now.ToString("R"));
            headers.Add("EXT", "");
            headers.Add("LOCATION", dev.Descriptor.ToString());
            headers.Add("SERVER", _serverSignature);
            headers.Add("ST", dev.Type);
            headers.Add("USN", dev.USN);

            SendDatagram(endpoint, String.Format("HTTP/1.1 200 OK\r\n{0}\r\n", headers.HeaderBlock), false);
            _logger.Info("{1} - Responded to a {0} request", dev.Type, endpoint);
        }
开发者ID:Rycius,项目名称:MediaBrowser,代码行数:14,代码来源:SsdpHandler.cs


注:本文中的Headers.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。