本文整理汇总了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
}
示例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;
}
示例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
示例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);
}