aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer
diff options
context:
space:
mode:
authorUbitUmarov2018-12-03 13:51:45 +0000
committerUbitUmarov2018-12-03 13:51:45 +0000
commit037de89a751df98f8d0c950c08df6e46326ae00e (patch)
treef6f793a0f442f0ba879566df3e1fb08485387741 /OpenSim/Framework/Servers/HttpServer
parentavoid a data copy (diff)
downloadopensim-SC-037de89a751df98f8d0c950c08df6e46326ae00e.zip
opensim-SC-037de89a751df98f8d0c950c08df6e46326ae00e.tar.gz
opensim-SC-037de89a751df98f8d0c950c08df6e46326ae00e.tar.bz2
opensim-SC-037de89a751df98f8d0c950c08df6e46326ae00e.tar.xz
clean a bit
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs10
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs18
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs99
3 files changed, 57 insertions, 70 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index fe3b8a0..5bb3fe2 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -604,7 +604,7 @@ namespace OpenSim.Framework.Servers.HttpServer
604 return; 604 return;
605 } 605 }
606 606
607 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 607 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request));
608 608
609 HandleRequest(req, resp); 609 HandleRequest(req, resp);
610 610
@@ -676,8 +676,6 @@ namespace OpenSim.Framework.Servers.HttpServer
676// } 676// }
677// } 677// }
678 678
679 response.SendChunked = false;
680
681 string path = request.RawUrl; 679 string path = request.RawUrl;
682 string handlerKey = GetHandlerKey(request.HttpMethod, path); 680 string handlerKey = GetHandlerKey(request.HttpMethod, path);
683 byte[] buffer = null; 681 byte[] buffer = null;
@@ -1308,7 +1306,6 @@ namespace OpenSim.Framework.Servers.HttpServer
1308 1306
1309 byte[] buffer = Encoding.UTF8.GetBytes(responseString); 1307 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
1310 1308
1311 response.SendChunked = false;
1312 response.ContentLength64 = buffer.Length; 1309 response.ContentLength64 = buffer.Length;
1313 response.ContentEncoding = Encoding.UTF8; 1310 response.ContentEncoding = Encoding.UTF8;
1314 1311
@@ -1480,7 +1477,6 @@ namespace OpenSim.Framework.Servers.HttpServer
1480 buffer = BuildLLSDResponse(request, response, llsdResponse); 1477 buffer = BuildLLSDResponse(request, response, llsdResponse);
1481 } 1478 }
1482 1479
1483 response.SendChunked = false;
1484 response.ContentLength64 = buffer.Length; 1480 response.ContentLength64 = buffer.Length;
1485 response.ContentEncoding = Encoding.UTF8; 1481 response.ContentEncoding = Encoding.UTF8;
1486 response.KeepAlive = true; 1482 response.KeepAlive = true;
@@ -1988,7 +1984,6 @@ namespace OpenSim.Framework.Servers.HttpServer
1988 buffer = Convert.FromBase64String(responseString); 1984 buffer = Convert.FromBase64String(responseString);
1989 } 1985 }
1990 1986
1991 response.SendChunked = false;
1992 response.ContentLength64 = buffer.Length; 1987 response.ContentLength64 = buffer.Length;
1993 response.ContentEncoding = Encoding.UTF8; 1988 response.ContentEncoding = Encoding.UTF8;
1994 } 1989 }
@@ -2005,7 +2000,6 @@ namespace OpenSim.Framework.Servers.HttpServer
2005 string responseString = GetHTTP404(host); 2000 string responseString = GetHTTP404(host);
2006 byte[] buffer = Encoding.UTF8.GetBytes(responseString); 2001 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
2007 2002
2008 response.SendChunked = false;
2009 response.ContentLength64 = buffer.Length; 2003 response.ContentLength64 = buffer.Length;
2010 response.ContentEncoding = Encoding.UTF8; 2004 response.ContentEncoding = Encoding.UTF8;
2011 2005
@@ -2021,11 +2015,9 @@ namespace OpenSim.Framework.Servers.HttpServer
2021 string responseString = GetHTTP500(); 2015 string responseString = GetHTTP500();
2022 byte[] buffer = Encoding.UTF8.GetBytes(responseString); 2016 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
2023 2017
2024 response.SendChunked = false;
2025 response.ContentLength64 = buffer.Length; 2018 response.ContentLength64 = buffer.Length;
2026 response.ContentEncoding = Encoding.UTF8; 2019 response.ContentEncoding = Encoding.UTF8;
2027 2020
2028
2029 return buffer; 2021 return buffer;
2030 } 2022 }
2031 2023
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
index 39d9b13..5a49881 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
@@ -251,12 +251,12 @@ namespace OpenSim.Framework.Servers.HttpServer
251 { 251 {
252 get 252 get
253 { 253 {
254 return _httpResponse.Chunked; 254 return _httpResponse.Chunked;
255 } 255 }
256 256
257 set 257 set
258 { 258 {
259 _httpResponse.Chunked = value; 259 _httpResponse.Chunked = value;
260 } 260 }
261 } 261 }
262 262
@@ -294,7 +294,6 @@ namespace OpenSim.Framework.Servers.HttpServer
294 } 294 }
295 295
296 protected IHttpResponse _httpResponse; 296 protected IHttpResponse _httpResponse;
297 private IHttpClientContext _httpClientContext;
298 297
299 public OSHttpResponse() {} 298 public OSHttpResponse() {}
300 299
@@ -312,12 +311,12 @@ namespace OpenSim.Framework.Servers.HttpServer
312 public OSHttpResponse(OSHttpRequest req) 311 public OSHttpResponse(OSHttpRequest req)
313 { 312 {
314 _httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest); 313 _httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest);
315 _httpClientContext = req.IHttpClientContext; 314
316 } 315 }
317 public OSHttpResponse(HttpResponse resp, IHttpClientContext clientContext) 316
317 public OSHttpResponse(HttpResponse resp)
318 { 318 {
319 _httpResponse = resp; 319 _httpResponse = resp;
320 _httpClientContext = clientContext;
321 } 320 }
322 321
323 /// <summary> 322 /// <summary>
@@ -337,13 +336,8 @@ namespace OpenSim.Framework.Servers.HttpServer
337 /// </summary> 336 /// </summary>
338 public void Send() 337 public void Send()
339 { 338 {
339 _httpResponse.Chunked = false;
340 _httpResponse.Send(); 340 _httpResponse.Send();
341 } 341 }
342
343 public void FreeContext()
344 {
345 if (_httpClientContext != null)
346 _httpClientContext.Close();
347 }
348 } 342 }
349} \ No newline at end of file 343} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
index 47a0b9c..f83b771 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
@@ -85,7 +85,13 @@ namespace OpenSim.Framework.Servers.HttpServer
85 Request.Body.Dispose(); 85 Request.Body.Dispose();
86 86
87 OSHttpResponse response 87 OSHttpResponse response
88 = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); 88 = new OSHttpResponse(new HttpResponse(HttpContext, Request));
89
90 if (responsedata == null)
91 {
92 SendNoContentError(response);
93 return;
94 }
89 95
90 int responsecode = 200; 96 int responsecode = 200;
91 string responseString = String.Empty; 97 string responseString = String.Empty;
@@ -94,61 +100,44 @@ namespace OpenSim.Framework.Servers.HttpServer
94 int rangeStart = 0; 100 int rangeStart = 0;
95 int rangeLen = -1; 101 int rangeLen = -1;
96 102
97 if (responsedata == null) 103 try
98 {
99 responsecode = 500;
100 responseString = "No response could be obtained";
101 contentType = "text/plain";
102 responsedata = new Hashtable();
103 }
104 else
105 { 104 {
106 try 105 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
107 { 106 if(responsedata["int_response_code"] != null)
108 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); 107 responsecode = (int)responsedata["int_response_code"];
109 if(responsedata["int_response_code"] != null) 108
110 responsecode = (int)responsedata["int_response_code"]; 109 if (responsedata["bin_response_data"] != null)
111
112 if (responsedata["bin_response_data"] != null)
113 {
114 buffer = (byte[])responsedata["bin_response_data"];
115 responsedata["bin_response_data"] = null;
116
117 if (responsedata["bin_start"] != null)
118 rangeStart = (int)responsedata["bin_start"];
119
120 if (responsedata["int_bytes"] != null)
121 rangeLen = (int)responsedata["int_bytes"];
122 }
123 else
124 responseString = (string)responsedata["str_response_string"];
125
126 contentType = (string)responsedata["content_type"];
127 if (responseString == null)
128 responseString = String.Empty;
129 }
130 catch
131 { 110 {
132 responsecode = 500; 111 buffer = (byte[])responsedata["bin_response_data"];
133 responseString = "No response could be obtained"; 112 responsedata["bin_response_data"] = null;
134 contentType = "text/plain"; 113
135 responsedata = new Hashtable(); 114 if (responsedata["bin_start"] != null)
115 rangeStart = (int)responsedata["bin_start"];
116
117 if (responsedata["int_bytes"] != null)
118 rangeLen = (int)responsedata["int_bytes"];
136 } 119 }
120 else
121 responseString = (string)responsedata["str_response_string"];
122
123 contentType = (string)responsedata["content_type"];
124 if (responseString == null)
125 responseString = String.Empty;
126 }
127 catch
128 {
129 SendNoContentError(response);
130 return;
137 } 131 }
138 132
139 if (responsedata.ContainsKey("error_status_text")) 133 if (responsedata.ContainsKey("error_status_text"))
140 {
141 response.StatusDescription = (string)responsedata["error_status_text"]; 134 response.StatusDescription = (string)responsedata["error_status_text"];
142 } 135
143 if (responsedata.ContainsKey("http_protocol_version")) 136 if (responsedata.ContainsKey("http_protocol_version"))
144 {
145 response.ProtocolVersion = (string)responsedata["http_protocol_version"]; 137 response.ProtocolVersion = (string)responsedata["http_protocol_version"];
146 } 138
147 if (responsedata.ContainsKey("keepalive")) 139 if (responsedata.ContainsKey("keepalive"))
148 { 140 response.KeepAlive = (bool)responsedata["keepalive"];
149 bool keepalive = (bool)responsedata["keepalive"];
150 response.KeepAlive = keepalive;
151 }
152 141
153 // Cross-Origin Resource Sharing with simple requests 142 // Cross-Origin Resource Sharing with simple requests
154 if (responsedata.ContainsKey("access_control_allow_origin")) 143 if (responsedata.ContainsKey("access_control_allow_origin"))
@@ -200,7 +189,6 @@ namespace OpenSim.Framework.Servers.HttpServer
200 else if (rangeLen + rangeStart > buffer.Length) 189 else if (rangeLen + rangeStart > buffer.Length)
201 rangeLen = buffer.Length - rangeStart; 190 rangeLen = buffer.Length - rangeStart;
202 191
203 response.SendChunked = false;
204 response.ContentLength64 = rangeLen; 192 response.ContentLength64 = rangeLen;
205 193
206 try 194 try
@@ -233,10 +221,24 @@ namespace OpenSim.Framework.Servers.HttpServer
233 PollServiceArgs.RequestsHandled++; 221 PollServiceArgs.RequestsHandled++;
234 } 222 }
235 223
224 internal void SendNoContentError(OSHttpResponse response)
225 {
226 response.ContentLength64 = 0;
227 response.ContentEncoding = Encoding.UTF8;
228 response.StatusCode = 500;
229
230 try
231 {
232 response.Send();
233 }
234 catch { }
235 return;
236 }
237
236 internal void DoHTTPstop() 238 internal void DoHTTPstop()
237 { 239 {
238 OSHttpResponse response 240 OSHttpResponse response
239 = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); 241 = new OSHttpResponse(new HttpResponse(HttpContext, Request));
240 242
241 if(Request.Body.CanRead) 243 if(Request.Body.CanRead)
242 Request.Body.Dispose(); 244 Request.Body.Dispose();
@@ -244,7 +246,6 @@ namespace OpenSim.Framework.Servers.HttpServer
244 response.ContentLength64 = 0; 246 response.ContentLength64 = 0;
245 response.ContentEncoding = Encoding.UTF8; 247 response.ContentEncoding = Encoding.UTF8;
246 response.KeepAlive = false; 248 response.KeepAlive = false;
247 response.SendChunked = false;
248 response.StatusCode = 503; 249 response.StatusCode = 503;
249 250
250 try 251 try