aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-05-03 01:45:49 +0100
committerJustin Clark-Casey (justincc)2012-05-03 01:45:49 +0100
commit231a3bf147315a9284140476d2b09e13c3fee1c0 (patch)
treef04ffb5bb43d919c1687af57e4cb48829f6dc437 /OpenSim/Framework/Servers
parentComment out the five second sleep in etm.DoTeleport() if the old agent needs ... (diff)
downloadopensim-SC_OLD-231a3bf147315a9284140476d2b09e13c3fee1c0.zip
opensim-SC_OLD-231a3bf147315a9284140476d2b09e13c3fee1c0.tar.gz
opensim-SC_OLD-231a3bf147315a9284140476d2b09e13c3fee1c0.tar.bz2
opensim-SC_OLD-231a3bf147315a9284140476d2b09e13c3fee1c0.tar.xz
Implement optional name and description on http stream handlers so that we can relate a slow request to what the handler actually does and the agent it serves, if applicable.
This is most useful for capabilities where the url is not self-describing.
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs10
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs16
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs10
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs9
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs17
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs21
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs6
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs20
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs14
9 files changed, 88 insertions, 35 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs
index 2fe9769..9f8f4a8 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs
@@ -33,9 +33,9 @@ namespace OpenSim.Framework.Servers.HttpServer
33 { 33 {
34 public abstract Hashtable Handle(string path, Hashtable Request); 34 public abstract Hashtable Handle(string path, Hashtable Request);
35 35
36 protected BaseHTTPHandler(string httpMethod, string path) 36 protected BaseHTTPHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
37 : base(httpMethod, path) 37
38 { 38 protected BaseHTTPHandler(string httpMethod, string path, string name, string description)
39 } 39 : base(httpMethod, path, name, description) {}
40 } 40 }
41} 41} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 0fbf90a..4ea4a1a 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -156,7 +156,7 @@ namespace OpenSim.Framework.Servers.HttpServer
156 } 156 }
157 } 157 }
158 158
159 public List<string> GetStreamHandlerKeys() 159 public List<string> GetStreamHandlerKeys()
160 { 160 {
161 lock (m_streamHandlers) 161 lock (m_streamHandlers)
162 return new List<string>(m_streamHandlers.Keys); 162 return new List<string>(m_streamHandlers.Keys);
@@ -410,6 +410,8 @@ namespace OpenSim.Framework.Servers.HttpServer
410// string reqnum = "unknown"; 410// string reqnum = "unknown";
411 int tickstart = Environment.TickCount; 411 int tickstart = Environment.TickCount;
412 412
413 IRequestHandler requestHandler = null;
414
413 try 415 try
414 { 416 {
415 // OpenSim.Framework.WebUtil.OSHeaderRequestID 417 // OpenSim.Framework.WebUtil.OSHeaderRequestID
@@ -438,8 +440,6 @@ namespace OpenSim.Framework.Servers.HttpServer
438 //response.KeepAlive = true; 440 //response.KeepAlive = true;
439 response.SendChunked = false; 441 response.SendChunked = false;
440 442
441 IRequestHandler requestHandler;
442
443 string path = request.RawUrl; 443 string path = request.RawUrl;
444 string handlerKey = GetHandlerKey(request.HttpMethod, path); 444 string handlerKey = GetHandlerKey(request.HttpMethod, path);
445 445
@@ -675,8 +675,16 @@ namespace OpenSim.Framework.Servers.HttpServer
675 // since its just for reporting, tickdiff limit can be adjusted 675 // since its just for reporting, tickdiff limit can be adjusted
676 int tickdiff = Environment.TickCount - tickstart; 676 int tickdiff = Environment.TickCount - tickstart;
677 if (tickdiff > 3000) 677 if (tickdiff > 3000)
678 {
678 m_log.InfoFormat( 679 m_log.InfoFormat(
679 "[BASE HTTP SERVER]: slow {0} request for {1} from {2} took {3} ms", requestMethod, uriString, request.RemoteIPEndPoint.ToString(), tickdiff); 680 "[BASE HTTP SERVER]: slow {0} for {1} {2} {3} from {4} took {5} ms",
681 requestMethod,
682 uriString,
683 requestHandler != null ? requestHandler.Name : "",
684 requestHandler != null ? requestHandler.Description : "",
685 request.RemoteIPEndPoint.ToString(),
686 tickdiff);
687 }
680 } 688 }
681 } 689 }
682 690
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
index a2135a3..ae7aaf2 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
@@ -45,8 +45,16 @@ namespace OpenSim.Framework.Servers.HttpServer
45 45
46 private readonly string m_path; 46 private readonly string m_path;
47 47
48 protected BaseRequestHandler(string httpMethod, string path) 48 public string Name { get; private set; }
49
50 public string Description { get; private set; }
51
52 protected BaseRequestHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
53
54 protected BaseRequestHandler(string httpMethod, string path, string name, string description)
49 { 55 {
56 Name = name;
57 Description = description;
50 m_httpMethod = httpMethod; 58 m_httpMethod = httpMethod;
51 m_path = path; 59 m_path = path;
52 } 60 }
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
index f1cde74..6342983 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
@@ -34,8 +34,9 @@ namespace OpenSim.Framework.Servers.HttpServer
34 public abstract byte[] Handle(string path, Stream request, 34 public abstract byte[] Handle(string path, Stream request,
35 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); 35 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse);
36 36
37 protected BaseStreamHandler(string httpMethod, string path) : base(httpMethod, path) 37 protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
38 { 38
39 } 39 protected BaseStreamHandler(string httpMethod, string path, string name, string description)
40 : base(httpMethod, path, name, description) {}
40 } 41 }
41} 42} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs
index 1699233..b94bfb4 100644
--- a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs
@@ -36,6 +36,15 @@ namespace OpenSim.Framework.Servers.HttpServer
36 { 36 {
37 private BinaryMethod m_method; 37 private BinaryMethod m_method;
38 38
39 public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod)
40 : this(httpMethod, path, binaryMethod, null, null) {}
41
42 public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod, string name, string description)
43 : base(httpMethod, path, name, description)
44 {
45 m_method = binaryMethod;
46 }
47
39 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 48 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
40 { 49 {
41 byte[] data = ReadFully(request); 50 byte[] data = ReadFully(request);
@@ -45,12 +54,6 @@ namespace OpenSim.Framework.Servers.HttpServer
45 return Encoding.UTF8.GetBytes(responseString); 54 return Encoding.UTF8.GetBytes(responseString);
46 } 55 }
47 56
48 public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod)
49 : base(httpMethod, path)
50 {
51 m_method = binaryMethod;
52 }
53
54 private static byte[] ReadFully(Stream stream) 57 private static byte[] ReadFully(Stream stream)
55 { 58 {
56 byte[] buffer = new byte[1024]; 59 byte[] buffer = new byte[1024];
@@ -70,4 +73,4 @@ namespace OpenSim.Framework.Servers.HttpServer
70 } 73 }
71 } 74 }
72 } 75 }
73} 76} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
index a449c2d..cb5cce5 100644
--- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
@@ -32,6 +32,25 @@ namespace OpenSim.Framework.Servers.HttpServer
32{ 32{
33 public interface IRequestHandler 33 public interface IRequestHandler
34 { 34 {
35
36 /// <summary>
37 /// Name for this handler.
38 /// </summary>
39 /// <remarks>
40 /// Used for diagnostics. The path doesn't always describe what the handler does. Can be null if none
41 /// specified.
42 /// </remarks>
43 string Name { get; }
44
45 /// <summary>
46 /// Description for this handler.
47 /// </summary>
48 /// <remarks>
49 /// Used for diagnostics. The path doesn't always describe what the handler does. Can be null if none
50 /// specified.
51 /// </remarks>
52 string Description { get; }
53
35 // Return response content type 54 // Return response content type
36 string ContentType { get; } 55 string ContentType { get; }
37 56
@@ -58,4 +77,4 @@ namespace OpenSim.Framework.Servers.HttpServer
58 { 77 {
59 Hashtable Handle(string path, Hashtable request); 78 Hashtable Handle(string path, Hashtable request);
60 } 79 }
61} 80} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
index a467a83..07082a8 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
@@ -39,7 +39,11 @@ namespace OpenSim.Framework.Servers.HttpServer
39 private RestDeserialiseMethod<TRequest, TResponse> m_method; 39 private RestDeserialiseMethod<TRequest, TResponse> m_method;
40 40
41 public RestDeserialiseHandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method) 41 public RestDeserialiseHandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method)
42 : base(httpMethod, path) 42 : this(httpMethod, path, method, null, null) {}
43
44 public RestDeserialiseHandler(
45 string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method, string name, string description)
46 : base(httpMethod, path, name, description)
43 { 47 {
44 m_method = method; 48 m_method = method;
45 } 49 }
diff --git a/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs
index 1f23cac..7f89839 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs
@@ -38,19 +38,25 @@ namespace OpenSim.Framework.Servers.HttpServer
38 get { return m_dhttpMethod; } 38 get { return m_dhttpMethod; }
39 } 39 }
40 40
41 public override Hashtable Handle(string path, Hashtable request) 41 public RestHTTPHandler(string httpMethod, string path, GenericHTTPMethod dhttpMethod)
42 : base(httpMethod, path)
42 { 43 {
44 m_dhttpMethod = dhttpMethod;
45 }
46
47 public RestHTTPHandler(
48 string httpMethod, string path, GenericHTTPMethod dhttpMethod, string name, string description)
49 : base(httpMethod, path, name, description)
50 {
51 m_dhttpMethod = dhttpMethod;
52 }
43 53
54 public override Hashtable Handle(string path, Hashtable request)
55 {
44 string param = GetParam(path); 56 string param = GetParam(path);
45 request.Add("param", param); 57 request.Add("param", param);
46 request.Add("path", path); 58 request.Add("path", path);
47 return m_dhttpMethod(request); 59 return m_dhttpMethod(request);
48 } 60 }
49
50 public RestHTTPHandler(string httpMethod, string path, GenericHTTPMethod dhttpMethod)
51 : base(httpMethod, path)
52 {
53 m_dhttpMethod = dhttpMethod;
54 }
55 } 61 }
56} 62}
diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
index d2c4002..1f17fee 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
@@ -39,6 +39,15 @@ namespace OpenSim.Framework.Servers.HttpServer
39 get { return m_restMethod; } 39 get { return m_restMethod; }
40 } 40 }
41 41
42 public RestStreamHandler(string httpMethod, string path, RestMethod restMethod)
43 : this(httpMethod, path, restMethod, null, null) {}
44
45 public RestStreamHandler(string httpMethod, string path, RestMethod restMethod, string name, string description)
46 : base(httpMethod, path, name, description)
47 {
48 m_restMethod = restMethod;
49 }
50
42 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 51 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
43 { 52 {
44 Encoding encoding = Encoding.UTF8; 53 Encoding encoding = Encoding.UTF8;
@@ -52,10 +61,5 @@ namespace OpenSim.Framework.Servers.HttpServer
52 61
53 return Encoding.UTF8.GetBytes(responseString); 62 return Encoding.UTF8.GetBytes(responseString);
54 } 63 }
55
56 public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base(httpMethod, path)
57 {
58 m_restMethod = restMethod;
59 }
60 } 64 }
61} 65}