aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs90
1 files changed, 69 insertions, 21 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index b24336d..e3f2e7a 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -366,6 +366,7 @@ namespace OpenSim.Framework.Servers.HttpServer
366 StreamReader reader = new StreamReader(requestStream, encoding); 366 StreamReader reader = new StreamReader(requestStream, encoding);
367 367
368 string requestBody = reader.ReadToEnd(); 368 string requestBody = reader.ReadToEnd();
369 reader.Close();
369 370
370 Hashtable keysvals = new Hashtable(); 371 Hashtable keysvals = new Hashtable();
371 Hashtable headervals = new Hashtable(); 372 Hashtable headervals = new Hashtable();
@@ -682,7 +683,7 @@ namespace OpenSim.Framework.Servers.HttpServer
682 // Every month or so this will wrap and give bad numbers, not really a problem 683 // Every month or so this will wrap and give bad numbers, not really a problem
683 // since its just for reporting 684 // since its just for reporting
684 int tickdiff = requestEndTick - requestStartTick; 685 int tickdiff = requestEndTick - requestStartTick;
685 if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") 686 if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture"))
686 { 687 {
687 m_log.InfoFormat( 688 m_log.InfoFormat(
688 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", 689 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
@@ -1603,10 +1604,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1603 1604
1604 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) 1605 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
1605 { 1606 {
1606 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); 1607 int responsecode;
1607 int responsecode = (int)responsedata["int_response_code"]; 1608 string responseString = String.Empty;
1608 string responseString = (string)responsedata["str_response_string"]; 1609 byte[] responseData = null;
1609 string contentType = (string)responsedata["content_type"]; 1610 string contentType;
1611
1612 if (responsedata == null)
1613 {
1614 responsecode = 500;
1615 responseString = "No response could be obtained";
1616 contentType = "text/plain";
1617 responsedata = new Hashtable();
1618 }
1619 else
1620 {
1621 try
1622 {
1623 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
1624 responsecode = (int)responsedata["int_response_code"];
1625 if (responsedata["bin_response_data"] != null)
1626 responseData = (byte[])responsedata["bin_response_data"];
1627 else
1628 responseString = (string)responsedata["str_response_string"];
1629 contentType = (string)responsedata["content_type"];
1630 if (responseString == null)
1631 responseString = String.Empty;
1632 }
1633 catch
1634 {
1635 responsecode = 500;
1636 responseString = "No response could be obtained";
1637 contentType = "text/plain";
1638 responsedata = new Hashtable();
1639 }
1640 }
1610 1641
1611 if (responsedata.ContainsKey("error_status_text")) 1642 if (responsedata.ContainsKey("error_status_text"))
1612 { 1643 {
@@ -1651,25 +1682,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1651 1682
1652 response.AddHeader("Content-Type", contentType); 1683 response.AddHeader("Content-Type", contentType);
1653 1684
1685 if (responsedata.ContainsKey("headers"))
1686 {
1687 Hashtable headerdata = (Hashtable)responsedata["headers"];
1688
1689 foreach (string header in headerdata.Keys)
1690 response.AddHeader(header, (string)headerdata[header]);
1691 }
1692
1654 byte[] buffer; 1693 byte[] buffer;
1655 1694
1656 if (!(contentType.Contains("image") 1695 if (responseData != null)
1657 || contentType.Contains("x-shockwave-flash")
1658 || contentType.Contains("application/x-oar")
1659 || contentType.Contains("application/vnd.ll.mesh")))
1660 { 1696 {
1661 // Text 1697 buffer = responseData;
1662 buffer = Encoding.UTF8.GetBytes(responseString);
1663 } 1698 }
1664 else 1699 else
1665 { 1700 {
1666 // Binary! 1701 if (!(contentType.Contains("image")
1667 buffer = Convert.FromBase64String(responseString); 1702 || contentType.Contains("x-shockwave-flash")
1668 } 1703 || contentType.Contains("application/x-oar")
1704 || contentType.Contains("application/vnd.ll.mesh")))
1705 {
1706 // Text
1707 buffer = Encoding.UTF8.GetBytes(responseString);
1708 }
1709 else
1710 {
1711 // Binary!
1712 buffer = Convert.FromBase64String(responseString);
1713 }
1669 1714
1670 response.SendChunked = false; 1715 response.SendChunked = false;
1671 response.ContentLength64 = buffer.Length; 1716 response.ContentLength64 = buffer.Length;
1672 response.ContentEncoding = Encoding.UTF8; 1717 response.ContentEncoding = Encoding.UTF8;
1718 }
1673 1719
1674 return buffer; 1720 return buffer;
1675 } 1721 }
@@ -1749,8 +1795,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1749 m_httpListener2.Start(64); 1795 m_httpListener2.Start(64);
1750 1796
1751 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events 1797 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
1752 m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); 1798// m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000);
1753 m_PollServiceManager.Start(); 1799 m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000);
1754 HTTPDRunning = true; 1800 HTTPDRunning = true;
1755 1801
1756 //HttpListenerContext context; 1802 //HttpListenerContext context;
@@ -1784,7 +1830,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1784 1830
1785 public void httpServerException(object source, Exception exception) 1831 public void httpServerException(object source, Exception exception)
1786 { 1832 {
1787 m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); 1833 if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException"))
1834 return;
1835 m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
1788 /* 1836 /*
1789 if (HTTPDRunning)// && NotSocketErrors > 5) 1837 if (HTTPDRunning)// && NotSocketErrors > 5)
1790 { 1838 {
@@ -1801,7 +1849,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1801 HTTPDRunning = false; 1849 HTTPDRunning = false;
1802 try 1850 try
1803 { 1851 {
1804 m_PollServiceManager.Stop(); 1852// m_PollServiceManager.Stop();
1805 1853
1806 m_httpListener2.ExceptionThrown -= httpServerException; 1854 m_httpListener2.ExceptionThrown -= httpServerException;
1807 //m_httpListener2.DisconnectHandler = null; 1855 //m_httpListener2.DisconnectHandler = null;