本文整理汇总了C#中System.Net.ServicePoint.SetVersion方法的典型用法代码示例。如果您正苦于以下问题:C# ServicePoint.SetVersion方法的具体用法?C# ServicePoint.SetVersion怎么用?C# ServicePoint.SetVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.ServicePoint
的用法示例。
在下文中一共展示了ServicePoint.SetVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResponse
static int GetResponse (WebConnectionData data, ServicePoint sPoint,
byte [] buffer, int max)
{
int pos = 0;
string line = null;
bool lineok = false;
bool isContinue = false;
bool emptyFirstLine = false;
do {
if (data.ReadState == ReadState.Aborted)
return -1;
if (data.ReadState == ReadState.None) {
lineok = ReadLine (buffer, ref pos, max, ref line);
if (!lineok)
return 0;
if (line == null) {
emptyFirstLine = true;
continue;
}
emptyFirstLine = false;
data.ReadState = ReadState.Status;
string [] parts = line.Split (' ');
if (parts.Length < 2)
return -1;
if (String.Compare (parts [0], "HTTP/1.1", true) == 0) {
data.Version = HttpVersion.Version11;
sPoint.SetVersion (HttpVersion.Version11);
} else {
data.Version = HttpVersion.Version10;
sPoint.SetVersion (HttpVersion.Version10);
}
data.StatusCode = (int) UInt32.Parse (parts [1]);
if (parts.Length >= 3)
data.StatusDescription = String.Join (" ", parts, 2, parts.Length - 2);
else
data.StatusDescription = "";
if (pos >= max)
return pos;
}
emptyFirstLine = false;
if (data.ReadState == ReadState.Status) {
data.ReadState = ReadState.Headers;
data.Headers = new WebHeaderCollection ();
ArrayList headers = new ArrayList ();
bool finished = false;
while (!finished) {
if (ReadLine (buffer, ref pos, max, ref line) == false)
break;
if (line == null) {
// Empty line: end of headers
finished = true;
continue;
}
if (line.Length > 0 && (line [0] == ' ' || line [0] == '\t')) {
int count = headers.Count - 1;
if (count < 0)
break;
string prev = (string) headers [count] + line;
headers [count] = prev;
} else {
headers.Add (line);
}
}
if (!finished)
return 0;
foreach (string s in headers)
data.Headers.SetInternal (s);
if (data.StatusCode == (int) HttpStatusCode.Continue) {
sPoint.SendContinue = true;
if (pos >= max)
return pos;
if (data.request.ExpectContinue) {
data.request.DoContinueDelegate (data.StatusCode, data.Headers);
// Prevent double calls when getting the
// headers in several packets.
data.request.ExpectContinue = false;
}
data.ReadState = ReadState.None;
isContinue = true;
}
else {
data.ReadState = ReadState.Content;
return pos;
}
}
//.........这里部分代码省略.........