29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
37 namespace OpenSim.Framework.Servers.HttpServer
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 private void GenContextHash()
52 Random rnd =
new Random();
54 if (Request.Headers[
"remote_addr"] != null)
55 contextHash = (Request.Headers[
"remote_addr"]).GetHashCode() << 16;
57 contextHash = rnd.Next() << 16;
58 if (Request.Headers[
"remote_port"] != null)
60 string[] strPorts = Request.Headers[
"remote_port"].Split(
new char[] {
',' });
61 contextHash += Int32.Parse(strPorts[0]);
64 contextHash += rnd.Next() & 0xffff;
70 PollServiceArgs = pPollServiceArgs;
71 HttpContext = pHttpContext;
73 RequestTime = System.Environment.TickCount;
74 RequestID = UUID.Random();
78 internal void DoHTTPGruntWork(
BaseHttpServer server, Hashtable responsedata)
81 =
new OSHttpResponse(
new HttpResponse(HttpContext, Request), HttpContext);
83 byte[] buffer = server.DoHTTPGruntWork(responsedata, response);
85 response.SendChunked =
false;
86 response.ContentLength64 = buffer.Length;
87 response.ContentEncoding = Encoding.UTF8;
88 response.ReuseContext =
false;
92 response.OutputStream.Write(buffer, 0, buffer.Length);
93 response.OutputStream.Flush();
99 m_log.Warn(
"[POLL SERVICE WORKER THREAD]: Error ", ex);
102 PollServiceArgs.RequestsHandled++;
105 internal void DoHTTPstop(BaseHttpServer server)
107 OSHttpResponse response
108 =
new OSHttpResponse(
new HttpResponse(HttpContext, Request), HttpContext);
110 response.SendChunked =
false;
111 response.ContentLength64 = 0;
112 response.ContentEncoding = Encoding.UTF8;
113 response.ReuseContext =
false;
114 response.KeepAlive =
false;
115 response.SendChunked =
false;
116 response.StatusCode = 503;
120 response.OutputStream.Flush();
135 bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext);
141 return (
int)b2.contextHash;
readonly PollServiceEventArgs PollServiceArgs
OSHttpResponse is the OpenSim representation of an HTTP response.
bool Equals(PollServiceHttpRequest b1, PollServiceHttpRequest b2)
int GetHashCode(PollServiceHttpRequest b2)
PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
readonly IHttpClientContext HttpContext
readonly IHttpRequest Request