aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs72
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs9
-rw-r--r--OpenSim/Framework/Servers/OSHttpRequest.cs20
-rw-r--r--OpenSim/Framework/Servers/OSHttpResponse.cs200
4 files changed, 101 insertions, 200 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
index 12caf81..081327e 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
@@ -1213,7 +1213,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1213 1213
1214 response.ContentLength64 = buffer.Length; 1214 response.ContentLength64 = buffer.Length;
1215 1215
1216 if (response.Headers.Get("Content-Encoding") == null) 1216 if (response.ContentEncoding == null)
1217 response.ContentEncoding = encoding; 1217 response.ContentEncoding = encoding;
1218 1218
1219 response.SendChunked = chunked; 1219 response.SendChunked = chunked;
@@ -1256,7 +1256,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1256 1256
1257 handled = true; 1257 handled = true;
1258 1258
1259 DumpHeaders(); 1259 // DumpHeaders();
1260 1260
1261 // if (request.InputStream != null) 1261 // if (request.InputStream != null)
1262 // { 1262 // {
@@ -1273,8 +1273,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1273 1273
1274 // Closing the outputstream should complete the transmission process 1274 // Closing the outputstream should complete the transmission process
1275 1275
1276 Rest.Log.DebugFormat("{0} Closing output stream", MsgId); 1276 Rest.Log.DebugFormat("{0} Sending response", MsgId);
1277 response.OutputStream.Close(); 1277 // response.OutputStream.Close();
1278 response.Send();
1278 1279
1279 } 1280 }
1280 1281
@@ -1292,44 +1293,35 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1292 1293
1293 internal void AddHeader(string hdr, string data) 1294 internal void AddHeader(string hdr, string data)
1294 { 1295 {
1295 if (Rest.DEBUG) 1296 if (Rest.DEBUG) Rest.Log.DebugFormat("{0} Adding header: <{1}: {2}>", MsgId, hdr, data);
1296 { 1297 response.AddHeader(hdr, data);
1297 Rest.Log.DebugFormat("{0} Adding header: <{1}: {2}>",
1298 MsgId, hdr, data);
1299 if (response.Headers.Get(hdr) != null)
1300 {
1301 Rest.Log.DebugFormat("{0} Multipe {1} headers will be generated>",
1302 MsgId, hdr);
1303 }
1304 }
1305 response.Headers.Add(hdr, data);
1306 }
1307
1308 internal void RemoveHeader(string hdr)
1309 {
1310 if (Rest.DEBUG)
1311 {
1312 Rest.Log.DebugFormat("{0} Removing header: <{1}>", MsgId, hdr);
1313 if (response.Headers.Get(hdr) == null)
1314 {
1315 Rest.Log.DebugFormat("{0} No such header existed",
1316 MsgId, hdr);
1317 }
1318 }
1319 response.Headers.Remove(hdr);
1320 } 1298 }
1321 1299
1322 internal void DumpHeaders() 1300 // internal void RemoveHeader(string hdr)
1323 { 1301 // {
1324 if (Rest.DEBUG) 1302 // if (Rest.DEBUG)
1325 { 1303 // {
1326 for (int i=0;i<response.Headers.Count;i++) 1304 // Rest.Log.DebugFormat("{0} Removing header: <{1}>", MsgId, hdr);
1327 { 1305 // if (response.Headers.Get(hdr) == null)
1328 Rest.Log.DebugFormat("{0} Header[{1}] : {2}", MsgId, i, 1306 // {
1329 response.Headers.Get(i)); 1307 // Rest.Log.DebugFormat("{0} No such header existed",
1330 } 1308 // MsgId, hdr);
1331 } 1309 // }
1332 } 1310 // }
1311 // response.Headers.Remove(hdr);
1312 // }
1313
1314 // internal void DumpHeaders()
1315 // {
1316 // if (Rest.DEBUG)
1317 // {
1318 // for (int i=0;i<response.Headers.Count;i++)
1319 // {
1320 // Rest.Log.DebugFormat("{0} Header[{1}] : {2}", MsgId, i,
1321 // response.Headers.Get(i));
1322 // }
1323 // }
1324 // }
1333 1325
1334 // Setup the XML writer for output 1326 // Setup the XML writer for output
1335 1327
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index d1c22d6..558b383 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -277,7 +277,7 @@ namespace OpenSim.Framework.Servers
277 } 277 }
278 278
279 IRequestHandler requestHandler; 279 IRequestHandler requestHandler;
280 response.KeepAlive = false; 280 response.KeepAlive = true;
281 response.SendChunked = false; 281 response.SendChunked = false;
282 282
283 string path = request.RawUrl; 283 string path = request.RawUrl;
@@ -634,7 +634,7 @@ namespace OpenSim.Framework.Servers
634 requestStream.Close(); 634 requestStream.Close();
635 635
636 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); 636 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
637 response.KeepAlive = false; 637 response.KeepAlive = true;
638 638
639 LLSD llsdRequest = null; 639 LLSD llsdRequest = null;
640 LLSD llsdResponse = null; 640 LLSD llsdResponse = null;
@@ -705,7 +705,7 @@ namespace OpenSim.Framework.Servers
705 response.SendChunked = false; 705 response.SendChunked = false;
706 response.ContentLength64 = buffer.Length; 706 response.ContentLength64 = buffer.Length;
707 response.ContentEncoding = Encoding.UTF8; 707 response.ContentEncoding = Encoding.UTF8;
708 response.KeepAlive = false; 708 response.KeepAlive = true;
709 709
710 try 710 try
711 { 711 {
@@ -928,7 +928,7 @@ namespace OpenSim.Framework.Servers
928 { 928 {
929 m_log.Warn("[HTTP-AGENT]: Error - " + e.Message); 929 m_log.Warn("[HTTP-AGENT]: Error - " + e.Message);
930 response.SendChunked = false; 930 response.SendChunked = false;
931 response.KeepAlive = false; 931 response.KeepAlive = true;
932 response.StatusCode = (int)OSHttpStatusCode.ServerErrorInternalError; 932 response.StatusCode = (int)OSHttpStatusCode.ServerErrorInternalError;
933 //response.OutputStream.Close(); 933 //response.OutputStream.Close();
934 try 934 try
@@ -1128,6 +1128,7 @@ namespace OpenSim.Framework.Servers
1128 int responsecode = (int)responsedata["int_response_code"]; 1128 int responsecode = (int)responsedata["int_response_code"];
1129 string responseString = (string)responsedata["str_response_string"]; 1129 string responseString = (string)responsedata["str_response_string"];
1130 string contentType = (string)responsedata["content_type"]; 1130 string contentType = (string)responsedata["content_type"];
1131
1131 if (responsedata.ContainsKey("error_status_text")) 1132 if (responsedata.ContainsKey("error_status_text"))
1132 { 1133 {
1133 response.StatusDescription = (string)responsedata["error_status_text"]; 1134 response.StatusDescription = (string)responsedata["error_status_text"];
diff --git a/OpenSim/Framework/Servers/OSHttpRequest.cs b/OpenSim/Framework/Servers/OSHttpRequest.cs
index c47fe10..4c7d7ce 100644
--- a/OpenSim/Framework/Servers/OSHttpRequest.cs
+++ b/OpenSim/Framework/Servers/OSHttpRequest.cs
@@ -42,9 +42,8 @@ namespace OpenSim.Framework.Servers
42 { 42 {
43 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 protected HttpServer.IHttpRequest _request = null; 45 protected IHttpRequest _request = null;
46 protected HttpServer.IHttpClientContext _context = null; 46 protected IHttpClientContext _context = null;
47
48 47
49 public string[] AcceptTypes 48 public string[] AcceptTypes
50 { 49 {
@@ -137,8 +136,15 @@ namespace OpenSim.Framework.Servers
137 } 136 }
138 private string _userAgent; 137 private string _userAgent;
139 138
139 internal IHttpRequest IHttpRequest
140 {
141 get { return _request; }
142 }
140 143
141 144 internal IHttpClientContext IHttpClientContext
145 {
146 get { return _context; }
147 }
142 148
143 /// <summary> 149 /// <summary>
144 /// Internal whiteboard for handlers to store temporary stuff 150 /// Internal whiteboard for handlers to store temporary stuff
@@ -151,11 +157,9 @@ namespace OpenSim.Framework.Servers
151 private Dictionary<string, object> _whiteboard = new Dictionary<string, object>(); 157 private Dictionary<string, object> _whiteboard = new Dictionary<string, object>();
152 158
153 159
154 public OSHttpRequest() 160 public OSHttpRequest() {}
155 {
156 }
157 161
158 public OSHttpRequest(HttpServer.IHttpClientContext context, HttpServer.IHttpRequest req) 162 public OSHttpRequest(IHttpClientContext context, IHttpRequest req)
159 { 163 {
160 _request = req; 164 _request = req;
161 _context = context; 165 _context = context;
diff --git a/OpenSim/Framework/Servers/OSHttpResponse.cs b/OpenSim/Framework/Servers/OSHttpResponse.cs
index 24bf340..6b20bf3 100644
--- a/OpenSim/Framework/Servers/OSHttpResponse.cs
+++ b/OpenSim/Framework/Servers/OSHttpResponse.cs
@@ -38,19 +38,8 @@ namespace OpenSim.Framework.Servers
38 /// OSHttpResponse is the OpenSim representation of an HTTP 38 /// OSHttpResponse is the OpenSim representation of an HTTP
39 /// response. 39 /// response.
40 /// </summary> 40 /// </summary>
41 /// <remarks>
42 /// OSHttpResponse is currently dual "homed" in that it support
43 /// both the .NET HttpListenerResponse and the HttpServer
44 /// HttpResponse (similar to OSHttpRequest); this duality is only
45 /// temporary and the .NET usage will disappear once the switch to
46 /// HttpServer is completed.
47 /// </remarks>
48 public class OSHttpResponse 41 public class OSHttpResponse
49 { 42 {
50
51 // property code below is a bit messy, will all resolve to
52 // harmony once we've completed the switch
53
54 /// <summary> 43 /// <summary>
55 /// Content type property. 44 /// Content type property.
56 /// </summary> 45 /// </summary>
@@ -62,22 +51,12 @@ namespace OpenSim.Framework.Servers
62 { 51 {
63 get 52 get
64 { 53 {
65 if (HttpServer) 54 return _httpResponse.ContentType;
66 return _httpResponse.ContentType;
67 else
68 return _httpListenerResponse.ContentType;
69 } 55 }
56
70 set 57 set
71 { 58 {
72 if (HttpServer) 59 _httpResponse.ContentType = value;
73 {
74 _httpResponse.ContentType = value;
75 }
76 else
77 {
78 _httpListenerResponse.ContentType = value;
79 _contentTypeSet = true;
80 }
81 } 60 }
82 } 61 }
83 62
@@ -102,17 +81,12 @@ namespace OpenSim.Framework.Servers
102 { 81 {
103 get 82 get
104 { 83 {
105 if (HttpServer) 84 return _httpResponse.ContentLength;
106 return _httpResponse.ContentLength;
107 else
108 return _httpListenerResponse.ContentLength64;
109 } 85 }
86
110 set 87 set
111 { 88 {
112 if (HttpServer) 89 _httpResponse.ContentLength = value;
113 _httpResponse.ContentLength = value;
114 else
115 _httpListenerResponse.ContentLength64 = value;
116 } 90 }
117 } 91 }
118 92
@@ -132,59 +106,55 @@ namespace OpenSim.Framework.Servers
132 { 106 {
133 get 107 get
134 { 108 {
135 if (HttpServer) 109 return _httpResponse.Encoding;
136 return _httpResponse.Encoding;
137 else
138 return _httpListenerResponse.ContentEncoding;
139 } 110 }
140 111
141 set 112 set
142 { 113 {
143 if (HttpServer) 114 _httpResponse.Encoding = value;
144 _httpResponse.Encoding = value;
145 else
146 _httpListenerResponse.ContentEncoding = value;
147 } 115 }
148 } 116 }
149 117
150 /// <summary> 118 public bool KeepAlive
151 /// Headers of the response.
152 /// </summary>
153 public WebHeaderCollection Headers
154 { 119 {
155 get 120 get
121 {
122 return _httpResponse.Connection == ConnectionType.KeepAlive;
123 }
124
125 set
156 { 126 {
157 if (HttpServer) 127 if (value)
158 return null; 128 _httpResponse.Connection = ConnectionType.KeepAlive;
159 else 129 else
160 return _httpListenerResponse.Headers; 130 _httpResponse.Connection = ConnectionType.Close;
161 } 131 }
162 } 132 }
163 133
164 /// <summary> 134 /// <summary>
165 /// Get or set the keep alive property. 135 /// Get or set the keep alive timeout property (default is
136 /// 20). Setting this to 0 also disables KeepAlive. Setting
137 /// this to something else but 0 also enable KeepAlive.
166 /// </summary> 138 /// </summary>
167 public bool KeepAlive 139 public int KeepAliveTimeout
168 { 140 {
169 get 141 get
170 { 142 {
171 if (HttpServer) 143 return _httpResponse.KeepAlive;
172 return _httpResponse.Connection == ConnectionType.KeepAlive;
173 else
174 return _httpListenerResponse.KeepAlive;
175 } 144 }
176 145
177 set 146 set
178 { 147 {
179 if (HttpServer) 148 if (value == 0)
180 { 149 {
181 if (value == true) 150 _httpResponse.Connection = ConnectionType.Close;
182 _httpResponse.Connection = ConnectionType.KeepAlive; 151 _httpResponse.KeepAlive = 0;
183 else
184 _httpResponse.Connection = ConnectionType.Close;
185 } 152 }
186 else 153 else
187 _httpListenerResponse.KeepAlive = value; 154 {
155 _httpResponse.Connection = ConnectionType.KeepAlive;
156 _httpResponse.KeepAlive = value;
157 }
188 } 158 }
189 } 159 }
190 160
@@ -198,10 +168,7 @@ namespace OpenSim.Framework.Servers
198 { 168 {
199 get 169 get
200 { 170 {
201 if (HttpServer) 171 return _httpResponse.Body;
202 return _httpResponse.Body;
203 else
204 return _httpListenerResponse.OutputStream;
205 } 172 }
206 } 173 }
207 174
@@ -209,18 +176,12 @@ namespace OpenSim.Framework.Servers
209 { 176 {
210 get 177 get
211 { 178 {
212 if (HttpServer) 179 return _httpResponse.ProtocolVersion;
213 return _httpResponse.ProtocolVersion;
214 else
215 return _httpListenerResponse.ProtocolVersion.ToString();
216 } 180 }
181
217 set 182 set
218 { 183 {
219 if (HttpServer) 184 _httpResponse.ProtocolVersion = value;
220 _httpResponse.ProtocolVersion = value;
221 else
222 _httpListenerResponse.ProtocolVersion = new Version(value); ;
223
224 } 185 }
225 } 186 }
226 187
@@ -231,9 +192,7 @@ namespace OpenSim.Framework.Servers
231 { 192 {
232 get 193 get
233 { 194 {
234 if (HttpServer) 195 return _httpResponse.Body;
235 return _httpResponse.Body;
236 throw new Exception("[OSHttpResponse] mixed .NET and HttpServer access");
237 } 196 }
238 } 197 }
239 198
@@ -245,10 +204,7 @@ namespace OpenSim.Framework.Servers
245 // get { return _redirectLocation; } 204 // get { return _redirectLocation; }
246 set 205 set
247 { 206 {
248 if (HttpServer) 207 _httpResponse.Redirect(value);
249 _httpResponse.Redirect(value);
250 else
251 _httpListenerResponse.RedirectLocation = value;
252 } 208 }
253 } 209 }
254 210
@@ -260,18 +216,12 @@ namespace OpenSim.Framework.Servers
260 { 216 {
261 get 217 get
262 { 218 {
263 if (HttpServer)
264 return _httpResponse.Chunked; 219 return _httpResponse.Chunked;
265 else
266 return _httpListenerResponse.SendChunked;
267 } 220 }
268 221
269 set 222 set
270 { 223 {
271 if (HttpServer) 224 _httpResponse.Chunked = value;
272 _httpResponse.Chunked = value;
273 else
274 _httpListenerResponse.SendChunked = value;
275 } 225 }
276 } 226 }
277 227
@@ -282,18 +232,12 @@ namespace OpenSim.Framework.Servers
282 { 232 {
283 get 233 get
284 { 234 {
285 if (HttpServer) 235 return (int)_httpResponse.Status;
286 return (int)_httpResponse.Status;
287 else
288 return _httpListenerResponse.StatusCode;
289 } 236 }
290 237
291 set 238 set
292 { 239 {
293 if (HttpServer) 240 _httpResponse.Status = (HttpStatusCode)value;
294 _httpResponse.Status = (HttpStatusCode)value;
295 else
296 _httpListenerResponse.StatusCode = value;
297 } 241 }
298 } 242 }
299 243
@@ -305,64 +249,35 @@ namespace OpenSim.Framework.Servers
305 { 249 {
306 get 250 get
307 { 251 {
308 if (HttpServer) 252 return _httpResponse.Reason;
309 return _httpResponse.Reason;
310 else
311 return _httpListenerResponse.StatusDescription;
312 } 253 }
313 254
314 set 255 set
315 { 256 {
316 if (HttpServer) 257 _httpResponse.Reason = value;
317 _httpResponse.Reason = value;
318 else
319 _httpListenerResponse.StatusDescription = value;
320 } 258 }
321 } 259 }
322 260
323 261
324 internal bool HttpServer 262 protected IHttpResponse _httpResponse;
325 {
326 get { return null != _httpResponse; }
327 }
328 private HttpResponse _httpResponse;
329 private HttpListenerResponse _httpListenerResponse;
330 263
331 internal HttpResponse HttpResponse 264 public OSHttpResponse() {}
332 {
333 get { return _httpResponse; }
334 }
335
336 public OSHttpResponse()
337 {
338 }
339 265
340 /// <summary> 266 public OSHttpResponse(IHttpResponse resp)
341 /// Instantiate an OSHttpResponse object based on an
342 /// underlying .NET HttpListenerResponse.
343 /// </summary>
344 /// <remarks>
345 /// Almost deprecated; will go west to make once HttpServer
346 /// base takes over.
347 /// </remarks>
348 public OSHttpResponse(HttpListenerResponse resp)
349 {
350 _httpListenerResponse = resp;
351 }
352 public OSHttpResponse(HttpServer.HttpResponse resp)
353 { 267 {
354 _httpResponse = resp; 268 _httpResponse = resp;
355 } 269 }
270
356 /// <summary> 271 /// <summary>
357 /// Instantiate an OSHttpResponse object from an OSHttpRequest 272 /// Instantiate an OSHttpResponse object from an OSHttpRequest
358 /// object. 273 /// object.
359 /// </summary 274 /// </summary
360 /// <param name="req">Incoming OSHttpRequest to which we are 275 /// <param name="req">Incoming OSHttpRequest to which we are
361 /// replying</param> 276 /// replying</param>
362 // public OSHttpResponse(OSHttpRequest req) 277 public OSHttpResponse(OSHttpRequest req)
363 // { 278 {
364 // _httpResponse = new HttpResponse(req.HttpClientContext, req.HttpRequest); 279 _httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest);
365 // } 280 }
366 281
367 /// <summary> 282 /// <summary>
368 /// Add a header field and content to the response. 283 /// Add a header field and content to the response.
@@ -373,10 +288,7 @@ namespace OpenSim.Framework.Servers
373 /// value</param> 288 /// value</param>
374 public void AddHeader(string key, string value) 289 public void AddHeader(string key, string value)
375 { 290 {
376 if (HttpServer) 291 _httpResponse.AddHeader(key, value);
377 _httpResponse.AddHeader(key, value);
378 else
379 _httpListenerResponse.Headers.Add(key, value);
380 } 292 }
381 293
382 /// <summary> 294 /// <summary>
@@ -384,16 +296,8 @@ namespace OpenSim.Framework.Servers
384 /// </summary> 296 /// </summary>
385 public void Send() 297 public void Send()
386 { 298 {
387 if (HttpServer) 299 _httpResponse.Body.Flush();
388 { 300 _httpResponse.Send();
389 _httpResponse.Body.Flush();
390 _httpResponse.Send();
391
392 }
393 else
394 {
395 OutputStream.Close();
396 }
397 } 301 }
398 } 302 }
399} 303}