本文整理汇总了C#中WebHeaderCollection类的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection类的具体用法?C# WebHeaderCollection怎么用?C# WebHeaderCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebHeaderCollection类属于命名空间,在下文中一共展示了WebHeaderCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChunkStream
public ChunkStream (WebHeaderCollection headers)
{
this.headers = headers;
saved = new StringBuilder ();
chunks = new ArrayList ();
chunkSize = -1;
}
示例2: HttpRequestHeader_GetKey_Success
public void HttpRequestHeader_GetKey_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
w.Add("header1", "value2");
Assert.NotEmpty(w.GetKey(0));
}
示例3: HttpListenerRequest
internal HttpListenerRequest (HttpListenerContext context)
{
this.context = context;
headers = new WebHeaderCollection ();
input_stream = Stream.Null;
version = HttpVersion.Version10;
}
示例4: ChunkStream
public ChunkStream(WebHeaderCollection headers)
{
_headers = headers;
_chunkSize = -1;
_chunks = new List<Chunk> ();
_saved = new StringBuilder ();
}
示例5: HeaderInfo
public static WebHeaderCollection HeaderInfo(String str)
{
WebHeaderCollection CC = new WebHeaderCollection();
HttpWebRequest Req = (HttpWebRequest)WebRequest.Create(str);
Req.Proxy = null;
Req.UseDefaultCredentials = true;
//YOU MUST ASSIGN A COOKIE CONTAINER FOR THE REQUEST TO PULL THE COOKIES
//Req.Headers = CC;
HttpWebResponse Res = (HttpWebResponse)Req.GetResponse();
//DUMP THE COOKIES
Console.WriteLine("----- HEADERS -----");
if(Res.Headers != null && Res.Headers.Count != 0)
{
foreach (string key in Res.Headers)
{
Console.WriteLine("\t" + key.ToString() + "\t" + Res.Headers[key]);
}
}
else
{
Console.WriteLine("No Headers");
}
return Res.Headers;
}
示例6: write
static void write(WebHeaderCollection headers)
{
for (int index = 0; index < headers.Count; index++) {
Console.WriteLine("{0}: {1}", headers.Keys[index], headers[index]);
}
Console.WriteLine("");
}
示例7: HttpRequestHeader_ToByteArray_Success
public void HttpRequestHeader_ToByteArray_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
w.Add("header1", "value2");
byte[] byteArr = w.ToByteArray();
Assert.NotEmpty(byteArr);
}
示例8: HttpRequest_AddQuery_CommonHeader_Success
public void HttpRequest_AddQuery_CommonHeader_Success()
{
string headerValue = "value123";
WebHeaderCollection w = new WebHeaderCollection();
w[HttpRequestHeader.Accept] = headerValue;
Assert.Equal(headerValue, w[HttpRequestHeader.Accept]);
}
示例9: DefaultPropertyValues_ReturnEmptyAfterConstruction_Success
public void DefaultPropertyValues_ReturnEmptyAfterConstruction_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Equal(0, w.AllKeys.Length);
Assert.Equal(0, w.Count);
Assert.Equal("\r\n", w.ToString());
Assert.Empty(w);
}
示例10: HttpRequestHeader_Get_Success
public void HttpRequestHeader_Get_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("header1", "value1");
w.Add("header1", "value2");
string[] values = w.GetValues(0);
Assert.Equal("value1", values[0]);
Assert.Equal("value2", values[1]);
}
示例11: HttpRequestHeader_Add_Success
public void HttpRequestHeader_Add_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w[HttpRequestHeader.Connection] = "keep-alive";
Assert.Equal(1, w.Count);
Assert.Equal("keep-alive", w[HttpRequestHeader.Connection]);
Assert.Equal("Connection", w.AllKeys[0]);
}
示例12: HttpResponseHeader_AddQuery_CommonHeader_Success
public void HttpResponseHeader_AddQuery_CommonHeader_Success()
{
string headerValue = "value123";
WebHeaderCollection w = new WebHeaderCollection();
w[HttpResponseHeader.ProxyAuthenticate] = headerValue;
w[HttpResponseHeader.WwwAuthenticate] = headerValue;
Assert.Equal(headerValue, w[HttpResponseHeader.ProxyAuthenticate]);
Assert.Equal(headerValue, w[HttpResponseHeader.WwwAuthenticate]);
}
示例13: CustomHeader_AddQuery_Success
public void CustomHeader_AddQuery_Success()
{
string customHeader = "Custom-Header";
string customValue = "Custom;.-Value";
WebHeaderCollection w = new WebHeaderCollection();
w[customHeader] = customValue;
Assert.Equal(1, w.Count);
Assert.Equal(customValue, w[customHeader]);
Assert.Equal(customHeader, w.AllKeys[0]);
}
示例14: HttpRequestHeader_Add_Remove_Success
public void HttpRequestHeader_Add_Remove_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add(HttpRequestHeader.Warning, "Warning1");
Assert.Equal(1, w.Count);
Assert.Equal("Warning1", w[HttpRequestHeader.Warning]);
Assert.Equal("Warning", w.AllKeys[0]);
w.Remove(HttpRequestHeader.Warning);
Assert.Equal(0, w.Count);
}
示例15: SerializeDeserialize_Roundtrip_MemberData
public static IEnumerable<object[]> SerializeDeserialize_Roundtrip_MemberData()
{
for (int i = 0; i < 10; i++)
{
var wc = new WebHeaderCollection();
for (int j = 0; j < i; j++)
{
wc[$"header{j}"] = $"value{j}";
}
yield return new object[] { wc };
}
}