diff options
author | Justin Clark-Casey (justincc) | 2012-06-15 02:51:52 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-06-15 02:51:52 +0100 |
commit | 94517c8d5c63f9e8a1ea9a83b04db956f27aa25d (patch) | |
tree | b38f309e24df668dc9b422daf69ce9273e09dee7 /OpenSim/Framework | |
parent | Add main instance to internal MainServer.m_Servers list to simplify internal ... (diff) | |
download | opensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.zip opensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.gz opensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.bz2 opensim-SC-94517c8d5c63f9e8a1ea9a83b04db956f27aa25d.tar.xz |
Make the "debug http" command available for robust as well as the simulator. This allows one to see incoming requests as they happen.
This required making everything use the common MainServer class for registering and retrieving http servers, rather than duplicate structures.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 3 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/MainServer.cs | 60 |
2 files changed, 59 insertions, 4 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 0db1329..3de7f9c 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -1557,6 +1557,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1557 | 1557 | ||
1558 | private void StartHTTP() | 1558 | private void StartHTTP() |
1559 | { | 1559 | { |
1560 | m_log.InfoFormat( | ||
1561 | "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); | ||
1562 | |||
1560 | try | 1563 | try |
1561 | { | 1564 | { |
1562 | //m_httpListener = new HttpListener(); | 1565 | //m_httpListener = new HttpListener(); |
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index becbbc2..07ff60c 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -30,13 +30,15 @@ using System.Collections.Generic; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Net; | 31 | using System.Net; |
32 | using log4net; | 32 | using log4net; |
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Console; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | 35 | using OpenSim.Framework.Servers.HttpServer; |
34 | 36 | ||
35 | namespace OpenSim.Framework.Servers | 37 | namespace OpenSim.Framework.Servers |
36 | { | 38 | { |
37 | public class MainServer | 39 | public class MainServer |
38 | { | 40 | { |
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | 42 | ||
41 | private static BaseHttpServer instance = null; | 43 | private static BaseHttpServer instance = null; |
42 | private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); | 44 | private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); |
@@ -88,6 +90,57 @@ namespace OpenSim.Framework.Servers | |||
88 | } | 90 | } |
89 | 91 | ||
90 | /// <summary> | 92 | /// <summary> |
93 | /// Get all the registered servers. | ||
94 | /// </summary> | ||
95 | /// <remarks> | ||
96 | /// Returns a copy of the dictionary so this can be iterated through without locking. | ||
97 | /// </remarks> | ||
98 | /// <value></value> | ||
99 | public static Dictionary<uint, BaseHttpServer> Servers | ||
100 | { | ||
101 | get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } | ||
102 | } | ||
103 | |||
104 | |||
105 | public static void RegisterHttpConsoleCommands(ICommandConsole console) | ||
106 | { | ||
107 | console.Commands.AddCommand( | ||
108 | "Comms", false, "debug http", "debug http [<level>]", | ||
109 | "Turn on inbound non-poll http request debugging.", | ||
110 | "If level <= 0, then no extra logging is done.\n" | ||
111 | + "If level >= 1, then short warnings are logged when receiving bad input data.\n" | ||
112 | + "If level >= 2, then long warnings are logged when receiving bad input data.\n" | ||
113 | + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" | ||
114 | + "If no level is specified then the current level is returned.", | ||
115 | HandleDebugHttpCommand); | ||
116 | } | ||
117 | |||
118 | /// <summary> | ||
119 | /// Turn on some debugging values for OpenSim. | ||
120 | /// </summary> | ||
121 | /// <param name="args"></param> | ||
122 | private static void HandleDebugHttpCommand(string module, string[] args) | ||
123 | { | ||
124 | if (args.Length == 3) | ||
125 | { | ||
126 | int newDebug; | ||
127 | if (int.TryParse(args[2], out newDebug)) | ||
128 | { | ||
129 | MainServer.DebugLevel = newDebug; | ||
130 | MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); | ||
131 | } | ||
132 | } | ||
133 | else if (args.Length == 2) | ||
134 | { | ||
135 | MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | MainConsole.Instance.Output("Usage: debug http 0..3"); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | /// <summary> | ||
91 | /// Register an already started HTTP server to the collection of known servers. | 144 | /// Register an already started HTTP server to the collection of known servers. |
92 | /// </summary> | 145 | /// </summary> |
93 | /// <param name='server'></param> | 146 | /// <param name='server'></param> |
@@ -171,11 +224,10 @@ namespace OpenSim.Framework.Servers | |||
171 | if (ipaddr != null) | 224 | if (ipaddr != null) |
172 | m_Servers[port].ListenIPAddress = ipaddr; | 225 | m_Servers[port].ListenIPAddress = ipaddr; |
173 | 226 | ||
174 | m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port); | ||
175 | m_Servers[port].Start(); | 227 | m_Servers[port].Start(); |
176 | } | ||
177 | 228 | ||
178 | return m_Servers[port]; | 229 | return m_Servers[port]; |
230 | } | ||
179 | } | 231 | } |
180 | } | 232 | } |
181 | } \ No newline at end of file | 233 | } \ No newline at end of file |