HttpWebRequest头部可用设置以及可读设置

来源:互联网 发布:我的世界自动瞄准js 编辑:程序博客网 时间:2024/06/11 03:56
注意:这是在Silverlight 1.1 Alpha中粗略测试的结果,如有错误,欢迎指正!

Alpha还是Alpha,连HttpWebRequest都这么不成熟,最常用的timeout属性居然既不能设置也不能更改,实在是郁闷!花了点时间,把所有的属性的读和写都测试了一遍。

能写的属性如下(其中被注释的表示不能写):
引用内容:
request.Accept = "text/*";
//request.Address.ToString();   readonly
//request.AllowAutoRedirect = true;
//request.AllowWriteStreamBuffering = true;
//request.AutomaticDecompression
request.Connection = "Close";
request.ContentLength = 256;
request.ContentType = "text/xml";
request.Expect = "100-Continue";
//request.HaveResponse.ToString();  readonly
request.Headers["Accept-Language"] = "zh-cn";
//request.KeepAlive = false;
//request.MediaType = "text/html";
request.Method = "POST";
//request.Pipelined = true;
//request.PreAuthenticate = true;
//request.ProtocolVersion = HttpVersion.Version10;
//request.ReadWriteTimeout = 10 * 1000;
request.Referer = "http://www.ooboy.net";
//request.RequestUri.ToString();    readonly
//request.SendChunked = true;
//request.Timeout = 10 * 1000;
request.TransferEncoding = "UTF-8";
//request.UserAgent = "Test Client";

能读的属性如下(其中被注释的表示不能读):
引用内容:
testInfo.Text = "Accept: " + request.Accept;
testInfo.Text += "/nAddress: " + request.Address.ToString();
testInfo.Text += "/nAllowAutoRedirect: " + request.AllowAutoRedirect.ToString();
testInfo.Text += "/nAllowWriteStreamBuffering: " + request.AllowWriteStreamBuffering.ToString();
testInfo.Text += "/nAutomaticDecompression: " + request.AutomaticDecompression.ToString();
testInfo.Text += "/nConnection: " + request.Connection;
testInfo.Text += "/nContentLength: " + request.ContentLength.ToString();    //设置后才可读
testInfo.Text += "/nContentType: " + request.ContentType;
testInfo.Text += "/nExpect: " + request.Expect;
testInfo.Text += "/nHaveResponse: " + request.HaveResponse.ToString();
testInfo.Text += "/nHeaders: " + request.Headers["Accept-Language"];
//testInfo.Text += "/nKeepAlive: " + request.KeepAlive.ToString();
//testInfo.Text += "/nMediaType: " + request.MediaType;
testInfo.Text += "/nMethod: " + request.Method;
//testInfo.Text += "/nPipelined: " + request.Pipelined.ToString();
//testInfo.Text += "/nPreAuthenticate: " + request.PreAuthenticate.ToString();
//testInfo.Text += "/nProtocolVersion: " + request.ProtocolVersion.ToString();
//testInfo.Text += "/nReadWriteTimeout: " + request.ReadWriteTimeout.ToString();
testInfo.Text += "/nReferer: " + request.Referer;
testInfo.Text += "/nRequestUri: " + request.RequestUri.ToString();
//testInfo.Text += "/nSendChunked: " + request.SendChunked.ToString();
//testInfo.Text += "/nTimeout: " + request.Timeout.ToString();
testInfo.Text += "/nTransferEncoding: " + request.TransferEncoding;
testInfo.Text += "/nUserAgent: " + request.UserAgent;

 

  原文地址:http://ooboy.net/blog/blogview.asp?logID=491&cateID=12
原创粉丝点击