本文整理汇总了C#中System.Net.Response.send方法的典型用法代码示例。如果您正苦于以下问题:C# Response.send方法的具体用法?C# Response.send怎么用?C# Response.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Response
的用法示例。
在下文中一共展示了Response.send方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewTcpClient
private void NewTcpClient(object obj)
{
var client = obj as TcpClient;
var stream = client.GetStream();
var handler = new ParserHandler();
var requ = new Request();
var context = new Context();
var response = new Response();
var parser = new HttpParser(handler);
handler.setData(requ);
int bytesRead = 0 ;
var buffer = new byte[1024 /* or whatever you like */];
try
{
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
if (bytesRead == parser.Execute(new ArraySegment<byte>(buffer, 0, bytesRead)))
break;
}
// ensure you get the last callbacks.
parser.Execute(default(ArraySegment<byte>));
logger.InfoFormat("[{0}] URI : {1}", requ.method,requ.uri);
var svc = this.router.route(requ.uri);
switch (requ.method)
{
case "GET" :
svc._get(context, requ, response);
break;
case "POST":
svc._post(context, requ, response);
break;
}
response.send(stream);
}
catch (Exception ex)
{
logger.ErrorFormat("exception: {0} ", ex.Message);
}
finally
{
stream.Close();
client.Close();
}
}