本文整理汇总了C#中WebHeaderCollection.SetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection.SetHeader方法的具体用法?C# WebHeaderCollection.SetHeader怎么用?C# WebHeaderCollection.SetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebHeaderCollection
的用法示例。
在下文中一共展示了WebHeaderCollection.SetHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClientHttpWebResponse
internal ClientHttpWebResponse (HttpWebRequest request, object response)
{
try {
content_length = (long) get_content_length.Invoke (response, null);
content_type = (string) get_content_type.Invoke (response, null);
response_uri = (Uri) get_response_uri.Invoke (response, null);
SetMethod ((string) get_method.Invoke (response, null));
SetStatus ((HttpStatusCode) (int) get_status_code.Invoke (response, null),
(string) get_status_description.Invoke (response, null));
jar = new CookieCollection ();
headers = new WebHeaderCollection ();
object header_collection = get_headers.Invoke (response, null);
string[] keys = ClientReflectionHelper.GetHeaderKeys (header_collection);
foreach (string key in keys) {
switch (key) {
case "Set-Cookie":
string[] values = ClientReflectionHelper.GetHeaderValues (header_collection, key);
foreach (string cookie in values)
SetCookie (cookie);
break;
default:
string value = ClientReflectionHelper.GetHeader (header_collection, key);
headers.SetHeader (key, value);
break;
}
}
using (Stream response_stream = (Stream) get_response_stream.Invoke (response, null)) {
MemoryStream ms = new MemoryStream ();
response_stream.CopyTo (ms);
stream = new InternalWebResponseStreamWrapper (ms, request.AllowReadStreamBuffering);
}
(response as IDisposable).Dispose ();
}
catch (TargetInvocationException tie) {
throw tie.InnerException;
}
}