dispose some tmp streams

avinationmerge
UbitUmarov 2014-09-17 15:36:22 +01:00
parent f254761649
commit 9bf3e2a257
1 changed files with 18 additions and 14 deletions

View File

@ -329,15 +329,16 @@ namespace OpenSim.Framework.Communications
return null; return null;
} }
Stream src = _response.GetResponseStream(); using (Stream src = _response.GetResponseStream())
int length = src.Read(_readbuf, 0, BufferSize);
while (length > 0)
{ {
_resource.Write(_readbuf, 0, length); int length = src.Read(_readbuf, 0, BufferSize);
length = src.Read(_readbuf, 0, BufferSize); while (length > 0)
{
_resource.Write(_readbuf, 0, length);
length = src.Read(_readbuf, 0, BufferSize);
}
} }
// TODO! Implement timeout, without killing the server // TODO! Implement timeout, without killing the server
// this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
//ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
@ -372,16 +373,19 @@ namespace OpenSim.Framework.Communications
m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri());
src.Seek(0, SeekOrigin.Begin); src.Seek(0, SeekOrigin.Begin);
m_log.Info("[REST]: Seek is ok"); m_log.Info("[REST]: Seek is ok");
Stream dst = _request.GetRequestStream();
m_log.Info("[REST]: GetRequestStream is ok");
byte[] buf = new byte[1024]; using (Stream dst = _request.GetRequestStream())
int length = src.Read(buf, 0, 1024);
m_log.Info("[REST]: First Read is ok");
while (length > 0)
{ {
dst.Write(buf, 0, length); m_log.Info("[REST]: GetRequestStream is ok");
length = src.Read(buf, 0, 1024);
byte[] buf = new byte[1024];
int length = src.Read(buf, 0, 1024);
m_log.Info("[REST]: First Read is ok");
while (length > 0)
{
dst.Write(buf, 0, length);
length = src.Read(buf, 0, 1024);
}
} }
_response = (HttpWebResponse) _request.GetResponse(); _response = (HttpWebResponse) _request.GetResponse();