本文整理汇总了C#中HttpRequest.parseContents方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest.parseContents方法的具体用法?C# HttpRequest.parseContents怎么用?C# HttpRequest.parseContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.parseContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: parse
//.........这里部分代码省略.........
continue;
}
if (request != null)
{
if ((index = received.IndexOf(getVerb)) != -1)
request.RequestType = getVerb;
if ((index = received.IndexOf(getVerb)) != -1)
request.RequestType = getVerb;
else if ((index = received.IndexOf(postVerb)) != -1)
request.RequestType = postVerb;
}
if (index != -1)
{
int spaceIndex = received.Substring(index).IndexOf(' ');
int httpIndex = received.IndexOf(httpVerb);
try
{
header.RawUrl = received.Substring(index + spaceIndex + 1, httpIndex - (index + spaceIndex) - 2);
}
catch (Exception)
{
Debug.Print("UNEXPECTED EXCEPTION on: " + received);
}
}
else if ((index = received.IndexOf(hostVerb)) != -1)
{
header.Host = received.Substring(index + hostVerb.Length);
}
else if ((index = received.IndexOf(connectionVerb)) != -1)
{
header.Connection = received.Substring(index + connectionVerb.Length);
}
else if ((index = received.IndexOf(acceptEncodingVerb)) != -1)
{
header.AcceptEncoding = received.Substring(index + acceptEncodingVerb.Length);
}
else if ((index = received.IndexOf(acceptLanguageVerb)) != -1)
{
header.AcceptLanguage = received.Substring(index + acceptLanguageVerb.Length);
}
else if ((index = received.IndexOf(acceptCharsetVerb)) != -1)
{
header.AcceptCharSet = received.Substring(index + acceptCharsetVerb.Length);
}
else if ((index = received.IndexOf(acceptVerb)) != -1)
{
header.Accept = received.Substring(index + acceptVerb.Length);
}
else if ((index = received.IndexOf(userAgentVerb)) != -1)
{
header.UserAgent = received.Substring(index + userAgentVerb.Length);
}
else if ((index = received.IndexOf(authorizationVerb)) != -1)
{
header.Authorization = received.Substring(index + authorizationVerb.Length);
}
else if ((index = received.IndexOf(cookieVerb)) != -1)
{
header.RawCookies = received.Substring(index + cookieVerb.Length);
}
else if ((index = received.IndexOf(contentLengthVerb)) != -1)
{
try
{
String l = received.Substring(index + contentLengthVerb.Length);
header.ContentLength = int.Parse(l);
}
catch (Exception e)
{
Debug.Print(e.ToString());
}
}
if (received.Length == 0)
{
if (request != null && request.RequestType == "POST")
{
// We expect to see a line following this empty one
lines.MoveNext();
String postParams = (String)lines.Current;
request.parseContents(postParams);
}
else if (response != null)
{
// We expect to see a line following this empty one
int length = header.ContentLength;
if(length == 0)
length = 256;
StringBuilder sb = new StringBuilder(length + 10);
while (lines.MoveNext())
{
sb.Append(lines.Current.ToString());
sb.Append('\n');
}
response.Contents = sb.ToString();
}
}
}
}