aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs39
1 files changed, 26 insertions, 13 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 3ca4187..78554c3 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -381,6 +381,8 @@ namespace OpenSim.Framework.Servers
381 string responseString = String.Empty; 381 string responseString = String.Empty;
382 382
383 Hashtable keysvals = new Hashtable(); 383 Hashtable keysvals = new Hashtable();
384 Hashtable headervals = new Hashtable();
385 string host = "";
384 386
385 string[] querystringkeys = request.QueryString.AllKeys; 387 string[] querystringkeys = request.QueryString.AllKeys;
386 string[] rHeaders = request.Headers.AllKeys; 388 string[] rHeaders = request.Headers.AllKeys;
@@ -391,12 +393,23 @@ namespace OpenSim.Framework.Servers
391 keysvals.Add(queryname, request.QueryString[queryname]); 393 keysvals.Add(queryname, request.QueryString[queryname]);
392 394
393 } 395 }
394 396
397 foreach (string headername in rHeaders)
398 {
399 //MainLog.Instance.Warn("HEADER", headername + "=" + request.Headers[headername]);
400 headervals[headername] = request.Headers[headername];
401 }
402
403 if (headervals.Contains("Host"))
404 {
405 host = (string)headervals["Host"];
406 }
407
395 if (keysvals.Contains("method")) 408 if (keysvals.Contains("method"))
396 { 409 {
397 MainLog.Instance.Warn("HTTP", "Contains Method"); 410 //MainLog.Instance.Warn("HTTP", "Contains Method");
398 string method = (string) keysvals["method"]; 411 string method = (string) keysvals["method"];
399 MainLog.Instance.Warn("HTTP", requestBody); 412 //MainLog.Instance.Warn("HTTP", requestBody);
400 GenericHTTPMethod requestprocessor; 413 GenericHTTPMethod requestprocessor;
401 bool foundHandler = TryGetHTTPHandler(method, out requestprocessor); 414 bool foundHandler = TryGetHTTPHandler(method, out requestprocessor);
402 if (foundHandler) 415 if (foundHandler)
@@ -409,14 +422,14 @@ namespace OpenSim.Framework.Servers
409 } 422 }
410 else 423 else
411 { 424 {
412 MainLog.Instance.Warn("HTTP", "Handler Not Found"); 425 //MainLog.Instance.Warn("HTTP", "Handler Not Found");
413 SendHTML404(response); 426 SendHTML404(response, host);
414 } 427 }
415 } 428 }
416 else 429 else
417 { 430 {
418 MainLog.Instance.Warn("HTTP", "No Method specified"); 431 //MainLog.Instance.Warn("HTTP", "No Method specified");
419 SendHTML404(response); 432 SendHTML404(response, host);
420 } 433 }
421 } 434 }
422 435
@@ -457,13 +470,13 @@ namespace OpenSim.Framework.Servers
457 470
458 471
459 } 472 }
460 public void SendHTML404(HttpListenerResponse response) 473 public void SendHTML404(HttpListenerResponse response, string host)
461 { 474 {
462 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s 475 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s
463 response.StatusCode = 200; 476 response.StatusCode = 200;
464 response.AddHeader("Content-type", "text/html"); 477 response.AddHeader("Content-type", "text/html");
465 478
466 string responseString = GetHTTP404(); 479 string responseString = GetHTTP404(host);
467 byte[] buffer = Encoding.UTF8.GetBytes(responseString); 480 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
468 481
469 response.SendChunked = false; 482 response.SendChunked = false;
@@ -558,11 +571,11 @@ namespace OpenSim.Framework.Servers
558 m_HTTPHandlers.Remove(GetHandlerKey(httpMethod, path)); 571 m_HTTPHandlers.Remove(GetHandlerKey(httpMethod, path));
559 } 572 }
560 573
561 public string GetHTTP404() 574 public string GetHTTP404(string host)
562 { 575 {
563 string file = Path.Combine(Util.configDir(), "http_404.html"); 576 string file = Path.Combine(Util.configDir(), "http_404.html");
564 if (!File.Exists(file)) 577 if (!File.Exists(file))
565 return getDefaultHTTP404(); 578 return getDefaultHTTP404(host);
566 579
567 StreamReader sr = File.OpenText(file); 580 StreamReader sr = File.OpenText(file);
568 string result = sr.ReadToEnd(); 581 string result = sr.ReadToEnd();
@@ -583,9 +596,9 @@ namespace OpenSim.Framework.Servers
583 } 596 }
584 597
585 // Fallback HTTP responses in case the HTTP error response files don't exist 598 // Fallback HTTP responses in case the HTTP error response files don't exist
586 private string getDefaultHTTP404() 599 private string getDefaultHTTP404(string host)
587 { 600 {
588 return "<HTML><HEAD><TITLE>404 Page not found</TITLE><BODY><BR /><H1>Ooops!</H1><P>The page you requested has been obsconded with by knomes. Find hippos quick!</P></BODY></HTML>"; 601 return "<HTML><HEAD><TITLE>404 Page not found</TITLE><BODY><BR /><H1>Ooops!</H1><P>The page you requested has been obsconded with by knomes. Find hippos quick!</P><P>If you are trying to log-in, your link parameters should have: &quot;-loginpage http://" + host + "/?method=login -loginuri http://" + host + "/&quot; in your link </P></BODY></HTML>";
589 } 602 }
590 603
591 private string getDefaultHTTP500() 604 private string getDefaultHTTP500()