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


C# ITransportHeaders.GetEnumerator方法代码示例

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


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

示例1: SendHeaders

		private static void SendHeaders(Stream networkStream, ITransportHeaders requestHeaders, byte[] buffer)
		{
			// Writes the headers as a sequence of strings
			if (networkStream != null)
			{
				IEnumerator e = requestHeaders.GetEnumerator();
				while (e.MoveNext())
				{
					DictionaryEntry hdr = (DictionaryEntry)e.Current;
					switch (hdr.Key.ToString())
					{
						case CommonTransportKeys.RequestUri: 
							networkStream.Write (msgUriTransportKey, 0, 4);
							break;
						case "Content-Type": 
							networkStream.Write (msgContentTypeTransportKey, 0, 4);
							break;
						default: 
							networkStream.Write (msgDefaultTransportKey, 0, 3);
							SendString (networkStream, hdr.Key.ToString(), buffer);
							networkStream.WriteByte (1);
							break;
					}
					SendString (networkStream, hdr.Value.ToString(), buffer);
				}
			}
			networkStream.Write (msgHeaderTerminator, 0, 2);	// End of headers
		}
开发者ID:nlhepler,项目名称:mono,代码行数:28,代码来源:TcpMessageIO.cs

示例2: CreateWebRequest

		private HttpWebRequest CreateWebRequest(string url, ITransportHeaders requestHeaders, Stream requestStream)
		{
			HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);;
			request.AllowAutoRedirect = _bAllowAutoRedirect;
			request.ContentLength = requestStream.Length;
			request.Credentials = GetCredenentials();
			//request.Expect = "100-Continue";
			
			//This caused us some troubles with the HttpWebResponse class
			//maybe its fixed now. TODO
			//request.KeepAlive = _useKeepAlive;
			request.KeepAlive = false;;
			
			request.Method = s_defaultVerb;
			request.Pipelined = false;
			request.SendChunked = _useChunked;
			request.UserAgent = s_userAgent;


			// write the remoting headers			
			IEnumerator headerenum = requestHeaders.GetEnumerator();
			while (headerenum.MoveNext()) 
			{
				DictionaryEntry entry = (DictionaryEntry) headerenum.Current;
				String key = entry.Key as String;
				if(key == "Content-Type")
				{
					request.ContentType = entry.Value.ToString();
					continue;
				}

				if (key == null || key.StartsWith("__")) 
				{
					continue;
				}

				request.Headers.Add(entry.Key.ToString(),entry.Value.ToString());
			}

			Stream reqStream = request.GetRequestStream();
			try {
				HttpHelper.CopyStream(requestStream, reqStream);
			} finally {
				reqStream.Close();
			}
			
			return request;
		}       
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:48,代码来源:HttpClientChannel.cs

示例3: WriteHeaders

        } // ReadToEndOfHeaders


        protected void WriteHeaders(ITransportHeaders headers, Stream outputStream)
        {
            IEnumerator it = null;
            BaseTransportHeaders wkHeaders = headers as BaseTransportHeaders;

            if (wkHeaders != null)
            {
                // write out well known headers
                //   NOTE: RequestUri is written out elsewhere.
            
                if (wkHeaders.ContentType != null)
                {
                    WriteContentTypeHeader(wkHeaders.ContentType, outputStream);
                }

                it = wkHeaders.GetOtherHeadersEnumerator();
            }
            else
            {
                it = headers.GetEnumerator();
            }

        
            // write custom headers
            if (it != null)
            {
                while (it.MoveNext())
                {
                    DictionaryEntry header = (DictionaryEntry)it.Current;
            
                    String headerName = (String)header.Key;

                    if (!StringHelper.StartsWithDoubleUnderscore(headerName)) // exclude special headers
                    {
                        String headerValue = header.Value.ToString();

                        if (wkHeaders == null)
                        {
                            if (String.Compare(headerName, "Content-Type", true, CultureInfo.InvariantCulture) == 0)
                            {
                                WriteContentTypeHeader(headerValue, outputStream);
                                continue;
                            }
                        }

                        WriteCustomHeader(headerName, headerValue, outputStream);
                    }                                
                } // while (it.MoveNext())            
            }

            // write EndOfHeaders token
            WriteUInt16(TcpHeaders.EndOfHeaders, outputStream);
        } // WriteHeaders
开发者ID:ArildF,项目名称:masters,代码行数:56,代码来源:tcpsocketmanager.cs

示例4: WriteHeaders

 protected void WriteHeaders(ITransportHeaders headers, Stream outputStream)
 {
     IEnumerator otherHeadersEnumerator = null;
     BaseTransportHeaders headers2 = headers as BaseTransportHeaders;
     if (headers2 != null)
     {
         if (headers2.ContentType != null)
         {
             this.WriteContentTypeHeader(headers2.ContentType, outputStream);
         }
         otherHeadersEnumerator = headers2.GetOtherHeadersEnumerator();
     }
     else
     {
         otherHeadersEnumerator = headers.GetEnumerator();
     }
     if (otherHeadersEnumerator != null)
     {
         while (otherHeadersEnumerator.MoveNext())
         {
             DictionaryEntry current = (DictionaryEntry) otherHeadersEnumerator.Current;
             string key = (string) current.Key;
             if (!StringHelper.StartsWithDoubleUnderscore(key))
             {
                 string str2 = current.Value.ToString();
                 if ((headers2 == null) && (string.Compare(key, "Content-Type", StringComparison.OrdinalIgnoreCase) == 0))
                 {
                     this.WriteContentTypeHeader(str2, outputStream);
                 }
                 else
                 {
                     this.WriteCustomHeader(key, str2, outputStream);
                 }
             }
         }
     }
     base.WriteUInt16(0, outputStream);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:38,代码来源:TcpSocketHandler.cs


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