本文整理汇总了C#中HTTPRequest.tryParse方法的典型用法代码示例。如果您正苦于以下问题:C# HTTPRequest.tryParse方法的具体用法?C# HTTPRequest.tryParse怎么用?C# HTTPRequest.tryParse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest.tryParse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: tryParseAppend
public bool tryParseAppend(ArraySegment<byte> input, int maxRequestLength)
{
progressiveRequestString += Encoding.ASCII.GetString(input.Array, 0, input.Count);
if (progressiveRequestString.StartsWith(GET))
{
if (progressiveRequestString.EndsWith(HEADER_END))
{
if (progressiveRequestString.Length > maxRequestLength)
{
throw new RequestEntityTooLargeResponsePage();
}
parse(progressiveRequestString);
progressiveRequestString = "";
return true;
}
return false;
}
else if (progressiveRequestString.StartsWith(POST))
{
HTTPRequest request = new HTTPRequest();
bool success = request.tryParse(progressiveRequestString);
if (success)
{
progressiveRequestString = "";
}
return success;
}
else
{
throw new BadRequestResponsePage();
}
}
示例2: connectionRead
private void connectionRead(AsynchronousServer.ClientConnection clientConnection)
{
ClientConnection cc = (ClientConnection)clientConnection;
try
{
if (cc.progressiveMessage.ToString().StartsWith(GET))
{
if (cc.progressiveMessage.ToString().EndsWith(HEADER_END))
{
HTTPRequest request = new HTTPRequest();
request.parse(cc.progressiveMessage.ToString());
processRequest(cc, request);
}
if (cc.progressiveMessage.Length > configuration.maxRequestLength)
{
throw new RequestEntityTooLargeResponsePage();
}
}
else if (cc.progressiveMessage.ToString().StartsWith(POST))
{
HTTPRequest request = new HTTPRequest();
if (request.tryParse(cc.progressiveMessage.ToString()))
{
processRequest(cc, request);
}
}
else
{
throw new BadRequestResponsePage();
}
}
catch (HTTPResponse r)
{
cc.Send(r);
}
catch (Exception e)
{
cc.Send(new ExceptionResponsePage(e.Message + " " + e.StackTrace));
}
}