本文整理汇总了C#中Aurora.Framework.Servers.HttpServer.OSHttpRequest.MakeResponse方法的典型用法代码示例。如果您正苦于以下问题:C# OSHttpRequest.MakeResponse方法的具体用法?C# OSHttpRequest.MakeResponse怎么用?C# OSHttpRequest.MakeResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aurora.Framework.Servers.HttpServer.OSHttpRequest
的用法示例。
在下文中一共展示了OSHttpRequest.MakeResponse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleUpstream
/// <summary>
/// Handle an message
/// </summary>
/// <param name="context">Context unique for this handler instance</param>
/// <param name="message">Message to process</param>
/// <remarks>
/// All messages that can't be handled MUST be send up the chain using <see cref="IPipelineHandlerContext.SendUpstream"/>.
/// </remarks>
public void HandleUpstream(IPipelineHandlerContext context, IPipelineMessage message)
{
var msg = message as ReceivedHttpRequest;
if (msg == null)
{
if (message is PipelineFailure)
MainConsole.Instance.ErrorFormat("[BaseHttpServer]: Failed to get message, {0}", (message as PipelineFailure).Exception);
return;
}
//MainConsole.Instance.Warn("Taking in request " + msg.HttpRequest.Uri.ToString());
var request = msg.HttpRequest;
PollServiceEventArgs psEvArgs;
OSHttpRequest req = new OSHttpRequest(context, request);
if (_server.TryGetPollServiceHTTPHandler(request.Uri.AbsolutePath, out psEvArgs))
{
PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request);
if (psEvArgs.Request != null)
{
string requestBody;
using (StreamReader reader = new StreamReader(req.InputStream, Encoding.UTF8))
requestBody = reader.ReadToEnd();
Hashtable keysvals = new Hashtable(), headervals = new Hashtable();
string[] querystringkeys = req.QueryString.AllKeys;
string[] rHeaders = req.Headers.AllKeys;
keysvals.Add("body", requestBody);
keysvals.Add("uri", req.RawUrl);
keysvals.Add("content-type", req.ContentType);
keysvals.Add("http-method", req.HttpMethod);
foreach (string queryname in querystringkeys)
keysvals.Add(queryname, req.QueryString[queryname]);
foreach (string headername in rHeaders)
headervals[headername] = req.Headers[headername];
keysvals.Add("headers", headervals);
keysvals.Add("querystringkeys", querystringkeys);
psEvArgs.Request(psreq.RequestID, keysvals);
}
_server.PollServiceManager.Enqueue(psreq);
}
else
HandleRequest(req, req.MakeResponse(HttpStatusCode.OK, "OK"));
}
示例2: Run
public void Run()
{
while (m_running)
{
PollServiceHttpRequest req = m_request.Dequeue();
try
{
if (req.PollServiceArgs.Valid())
{
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
{
StreamReader str;
try
{
str = new StreamReader(req.Request.Body);
}
catch (ArgumentException)
{
// Stream was not readable means a child agent
// was closed due to logout, leaving the
// Event Queue request orphaned.
continue;
}
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id,
str.ReadToEnd());
var request = new OSHttpRequest(req.HttpContext, req.Request);
m_server.MessageHandler.SendGenericHTTPResponse(
responsedata,
request.MakeResponse(System.Net.HttpStatusCode.OK, "OK"),
request
);
}
else
{
if ((Environment.TickCount - req.RequestTime) > m_timeout)
{
var request = new OSHttpRequest(req.HttpContext, req.Request);
m_server.MessageHandler.SendGenericHTTPResponse(
req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
request.MakeResponse(System.Net.HttpStatusCode.OK, "OK"),
request);
}
else
{
ReQueuePollServiceItem reQueueItem = ReQueue;
if (reQueueItem != null)
reQueueItem(req);
}
}
}
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat("Exception in poll service thread: " + e);
}
}
}