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