some cleanup, use more using(), more checks so http request mem stream is closed
parent
1107d0ccb9
commit
5fc3605955
|
@ -529,14 +529,10 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
if (psEvArgs.Request != null)
|
if (psEvArgs.Request != null)
|
||||||
{
|
{
|
||||||
OSHttpRequest req = new OSHttpRequest(context, request);
|
OSHttpRequest req = new OSHttpRequest(context, request);
|
||||||
|
string requestBody = String.Empty;
|
||||||
Stream requestStream = req.InputStream;
|
|
||||||
|
|
||||||
Encoding encoding = Encoding.UTF8;
|
Encoding encoding = Encoding.UTF8;
|
||||||
StreamReader reader = new StreamReader(requestStream, encoding);
|
using(StreamReader reader = new StreamReader(req.InputStream, encoding))
|
||||||
|
requestBody = reader.ReadToEnd();
|
||||||
string requestBody = reader.ReadToEnd();
|
|
||||||
reader.Close();
|
|
||||||
|
|
||||||
Hashtable keysvals = new Hashtable();
|
Hashtable keysvals = new Hashtable();
|
||||||
Hashtable headervals = new Hashtable();
|
Hashtable headervals = new Hashtable();
|
||||||
|
@ -630,6 +626,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
byte[] buffer500 = SendHTML500(response);
|
byte[] buffer500 = SendHTML500(response);
|
||||||
response.OutputStream.Write(buffer500, 0, buffer500.Length);
|
response.OutputStream.Write(buffer500, 0, buffer500.Length);
|
||||||
response.Send();
|
response.Send();
|
||||||
|
if(request.InputStream.CanRead)
|
||||||
|
request.InputStream.Close();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -674,7 +672,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//response.KeepAlive = true;
|
|
||||||
response.SendChunked = false;
|
response.SendChunked = false;
|
||||||
|
|
||||||
string path = request.RawUrl;
|
string path = request.RawUrl;
|
||||||
|
@ -698,15 +695,10 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
{
|
{
|
||||||
//m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler");
|
//m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler");
|
||||||
IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
|
IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
|
||||||
Stream requestStream = request.InputStream;
|
string requestBody = String.Empty;
|
||||||
|
|
||||||
Encoding encoding = Encoding.UTF8;
|
Encoding encoding = Encoding.UTF8;
|
||||||
StreamReader reader = new StreamReader(requestStream, encoding);
|
using(StreamReader reader = new StreamReader(request.InputStream, encoding))
|
||||||
|
requestBody = reader.ReadToEnd();
|
||||||
string requestBody = reader.ReadToEnd();
|
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
//requestStream.Close();
|
|
||||||
|
|
||||||
Hashtable keysvals = new Hashtable();
|
Hashtable keysvals = new Hashtable();
|
||||||
Hashtable headervals = new Hashtable();
|
Hashtable headervals = new Hashtable();
|
||||||
|
@ -746,7 +738,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IStreamHandler streamHandler = (IStreamHandler)requestHandler;
|
IStreamHandler streamHandler = (IStreamHandler)requestHandler;
|
||||||
|
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
using (MemoryStream memoryStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
streamHandler.Handle(path, request.InputStream, memoryStream, request, response);
|
streamHandler.Handle(path, request.InputStream, memoryStream, request, response);
|
||||||
|
@ -823,8 +814,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
request.InputStream.Close();
|
|
||||||
|
|
||||||
if (buffer != null)
|
if (buffer != null)
|
||||||
{
|
{
|
||||||
if (WebUtil.DebugLevel >= 5)
|
if (WebUtil.DebugLevel >= 5)
|
||||||
|
@ -856,10 +845,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
requestEndTick = Environment.TickCount;
|
requestEndTick = Environment.TickCount;
|
||||||
|
|
||||||
response.Send();
|
response.Send();
|
||||||
|
|
||||||
//response.OutputStream.Close();
|
|
||||||
|
|
||||||
//response.FreeContext();
|
|
||||||
}
|
}
|
||||||
catch (SocketException e)
|
catch (SocketException e)
|
||||||
{
|
{
|
||||||
|
@ -891,6 +876,9 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
if(request.InputStream.CanRead)
|
||||||
|
request.InputStream.Close();
|
||||||
|
|
||||||
// Every month or so this will wrap and give bad numbers, not really a problem
|
// Every month or so this will wrap and give bad numbers, not really a problem
|
||||||
// since its just for reporting
|
// since its just for reporting
|
||||||
int tickdiff = requestEndTick - requestStartTick;
|
int tickdiff = requestEndTick - requestStartTick;
|
||||||
|
@ -1148,8 +1136,9 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (innerStream != null)
|
if (innerStream != null && innerStream.CanRead)
|
||||||
innerStream.Dispose();
|
innerStream.Dispose();
|
||||||
|
if (requestStream.CanRead)
|
||||||
requestStream.Dispose();
|
requestStream.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1407,15 +1396,15 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
//m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
|
//m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
|
||||||
Stream requestStream = request.InputStream;
|
Stream requestStream = request.InputStream;
|
||||||
|
|
||||||
|
string requestBody = string.Empty;
|
||||||
Encoding encoding = Encoding.UTF8;
|
Encoding encoding = Encoding.UTF8;
|
||||||
StreamReader reader = new StreamReader(requestStream, encoding);
|
using(StreamReader reader = new StreamReader(requestStream,encoding))
|
||||||
|
requestBody = reader.ReadToEnd();
|
||||||
|
|
||||||
string requestBody = reader.ReadToEnd();
|
if(requestStream.CanRead)
|
||||||
reader.Close();
|
|
||||||
requestStream.Close();
|
requestStream.Close();
|
||||||
|
|
||||||
//m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
|
//m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
|
||||||
response.KeepAlive = true;
|
|
||||||
|
|
||||||
OSD llsdRequest = null;
|
OSD llsdRequest = null;
|
||||||
OSD llsdResponse = null;
|
OSD llsdResponse = null;
|
||||||
|
@ -1736,14 +1725,11 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
|
|
||||||
Stream requestStream = request.InputStream;
|
Stream requestStream = request.InputStream;
|
||||||
|
string requestBody = string.Empty;
|
||||||
Encoding encoding = Encoding.UTF8;
|
Encoding encoding = Encoding.UTF8;
|
||||||
StreamReader reader = new StreamReader(requestStream, encoding);
|
using(StreamReader reader = new StreamReader(requestStream,encoding))
|
||||||
|
requestBody = reader.ReadToEnd();
|
||||||
string requestBody = reader.ReadToEnd();
|
if(requestStream.CanRead)
|
||||||
// avoid warning for now
|
|
||||||
reader.ReadToEnd();
|
|
||||||
reader.Close();
|
|
||||||
requestStream.Close();
|
requestStream.Close();
|
||||||
|
|
||||||
Hashtable keysvals = new Hashtable();
|
Hashtable keysvals = new Hashtable();
|
||||||
|
@ -2283,10 +2269,9 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
string file = Path.Combine(".", "http_500.html");
|
string file = Path.Combine(".", "http_500.html");
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(file))
|
||||||
return getDefaultHTTP500();
|
return getDefaultHTTP500();
|
||||||
|
string result = string.Empty;
|
||||||
StreamReader sr = File.OpenText(file);
|
using(StreamReader sr = File.OpenText(file))
|
||||||
string result = sr.ReadToEnd();
|
result = sr.ReadToEnd();
|
||||||
sr.Close();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue