clean a bit
parent
66f3c6c730
commit
037de89a75
|
@ -604,7 +604,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
|
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request));
|
||||||
|
|
||||||
HandleRequest(req, resp);
|
HandleRequest(req, resp);
|
||||||
|
|
||||||
|
@ -676,8 +676,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
response.SendChunked = false;
|
|
||||||
|
|
||||||
string path = request.RawUrl;
|
string path = request.RawUrl;
|
||||||
string handlerKey = GetHandlerKey(request.HttpMethod, path);
|
string handlerKey = GetHandlerKey(request.HttpMethod, path);
|
||||||
byte[] buffer = null;
|
byte[] buffer = null;
|
||||||
|
@ -1308,7 +1306,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
|
|
||||||
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
|
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
|
||||||
|
|
||||||
response.SendChunked = false;
|
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
response.ContentEncoding = Encoding.UTF8;
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
@ -1480,7 +1477,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
buffer = BuildLLSDResponse(request, response, llsdResponse);
|
buffer = BuildLLSDResponse(request, response, llsdResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.SendChunked = false;
|
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
response.ContentEncoding = Encoding.UTF8;
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
response.KeepAlive = true;
|
response.KeepAlive = true;
|
||||||
|
@ -1988,7 +1984,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
buffer = Convert.FromBase64String(responseString);
|
buffer = Convert.FromBase64String(responseString);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.SendChunked = false;
|
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
response.ContentEncoding = Encoding.UTF8;
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
}
|
}
|
||||||
|
@ -2005,7 +2000,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
string responseString = GetHTTP404(host);
|
string responseString = GetHTTP404(host);
|
||||||
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
|
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
|
||||||
|
|
||||||
response.SendChunked = false;
|
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
response.ContentEncoding = Encoding.UTF8;
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
@ -2021,11 +2015,9 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
string responseString = GetHTTP500();
|
string responseString = GetHTTP500();
|
||||||
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
|
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
|
||||||
|
|
||||||
response.SendChunked = false;
|
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
response.ContentEncoding = Encoding.UTF8;
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IHttpResponse _httpResponse;
|
protected IHttpResponse _httpResponse;
|
||||||
private IHttpClientContext _httpClientContext;
|
|
||||||
|
|
||||||
public OSHttpResponse() {}
|
public OSHttpResponse() {}
|
||||||
|
|
||||||
|
@ -312,12 +311,12 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
public OSHttpResponse(OSHttpRequest req)
|
public OSHttpResponse(OSHttpRequest req)
|
||||||
{
|
{
|
||||||
_httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest);
|
_httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest);
|
||||||
_httpClientContext = req.IHttpClientContext;
|
|
||||||
}
|
}
|
||||||
public OSHttpResponse(HttpResponse resp, IHttpClientContext clientContext)
|
|
||||||
|
public OSHttpResponse(HttpResponse resp)
|
||||||
{
|
{
|
||||||
_httpResponse = resp;
|
_httpResponse = resp;
|
||||||
_httpClientContext = clientContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -337,13 +336,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Send()
|
public void Send()
|
||||||
{
|
{
|
||||||
|
_httpResponse.Chunked = false;
|
||||||
_httpResponse.Send();
|
_httpResponse.Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FreeContext()
|
|
||||||
{
|
|
||||||
if (_httpClientContext != null)
|
|
||||||
_httpClientContext.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -85,7 +85,13 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
Request.Body.Dispose();
|
Request.Body.Dispose();
|
||||||
|
|
||||||
OSHttpResponse response
|
OSHttpResponse response
|
||||||
= new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext);
|
= new OSHttpResponse(new HttpResponse(HttpContext, Request));
|
||||||
|
|
||||||
|
if (responsedata == null)
|
||||||
|
{
|
||||||
|
SendNoContentError(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int responsecode = 200;
|
int responsecode = 200;
|
||||||
string responseString = String.Empty;
|
string responseString = String.Empty;
|
||||||
|
@ -94,15 +100,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
int rangeStart = 0;
|
int rangeStart = 0;
|
||||||
int rangeLen = -1;
|
int rangeLen = -1;
|
||||||
|
|
||||||
if (responsedata == null)
|
|
||||||
{
|
|
||||||
responsecode = 500;
|
|
||||||
responseString = "No response could be obtained";
|
|
||||||
contentType = "text/plain";
|
|
||||||
responsedata = new Hashtable();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
|
//m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
|
||||||
|
@ -129,26 +126,18 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
responsecode = 500;
|
SendNoContentError(response);
|
||||||
responseString = "No response could be obtained";
|
return;
|
||||||
contentType = "text/plain";
|
|
||||||
responsedata = new Hashtable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responsedata.ContainsKey("error_status_text"))
|
if (responsedata.ContainsKey("error_status_text"))
|
||||||
{
|
|
||||||
response.StatusDescription = (string)responsedata["error_status_text"];
|
response.StatusDescription = (string)responsedata["error_status_text"];
|
||||||
}
|
|
||||||
if (responsedata.ContainsKey("http_protocol_version"))
|
if (responsedata.ContainsKey("http_protocol_version"))
|
||||||
{
|
|
||||||
response.ProtocolVersion = (string)responsedata["http_protocol_version"];
|
response.ProtocolVersion = (string)responsedata["http_protocol_version"];
|
||||||
}
|
|
||||||
if (responsedata.ContainsKey("keepalive"))
|
if (responsedata.ContainsKey("keepalive"))
|
||||||
{
|
response.KeepAlive = (bool)responsedata["keepalive"];
|
||||||
bool keepalive = (bool)responsedata["keepalive"];
|
|
||||||
response.KeepAlive = keepalive;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cross-Origin Resource Sharing with simple requests
|
// Cross-Origin Resource Sharing with simple requests
|
||||||
if (responsedata.ContainsKey("access_control_allow_origin"))
|
if (responsedata.ContainsKey("access_control_allow_origin"))
|
||||||
|
@ -200,7 +189,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
else if (rangeLen + rangeStart > buffer.Length)
|
else if (rangeLen + rangeStart > buffer.Length)
|
||||||
rangeLen = buffer.Length - rangeStart;
|
rangeLen = buffer.Length - rangeStart;
|
||||||
|
|
||||||
response.SendChunked = false;
|
|
||||||
response.ContentLength64 = rangeLen;
|
response.ContentLength64 = rangeLen;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -233,10 +221,24 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
PollServiceArgs.RequestsHandled++;
|
PollServiceArgs.RequestsHandled++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void SendNoContentError(OSHttpResponse response)
|
||||||
|
{
|
||||||
|
response.ContentLength64 = 0;
|
||||||
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
|
response.StatusCode = 500;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response.Send();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
internal void DoHTTPstop()
|
internal void DoHTTPstop()
|
||||||
{
|
{
|
||||||
OSHttpResponse response
|
OSHttpResponse response
|
||||||
= new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext);
|
= new OSHttpResponse(new HttpResponse(HttpContext, Request));
|
||||||
|
|
||||||
if(Request.Body.CanRead)
|
if(Request.Body.CanRead)
|
||||||
Request.Body.Dispose();
|
Request.Body.Dispose();
|
||||||
|
@ -244,7 +246,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
response.ContentLength64 = 0;
|
response.ContentLength64 = 0;
|
||||||
response.ContentEncoding = Encoding.UTF8;
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
response.KeepAlive = false;
|
response.KeepAlive = false;
|
||||||
response.SendChunked = false;
|
|
||||||
response.StatusCode = 503;
|
response.StatusCode = 503;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue