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 70c531c..27af009 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -395,6 +395,7 @@ namespace OpenSim.Framework.Servers.HttpServer
395 StreamReader reader = new StreamReader(requestStream, encoding); 395 StreamReader reader = new StreamReader(requestStream, encoding);
396 396
397 string requestBody = reader.ReadToEnd(); 397 string requestBody = reader.ReadToEnd();
398 reader.Close();
398 399
399 Hashtable keysvals = new Hashtable(); 400 Hashtable keysvals = new Hashtable();
400 Hashtable headervals = new Hashtable(); 401 Hashtable headervals = new Hashtable();
@@ -726,7 +727,7 @@ namespace OpenSim.Framework.Servers.HttpServer
726 // Every month or so this will wrap and give bad numbers, not really a problem 727 // Every month or so this will wrap and give bad numbers, not really a problem
727 // since its just for reporting 728 // since its just for reporting
728 int tickdiff = requestEndTick - requestStartTick; 729 int tickdiff = requestEndTick - requestStartTick;
729 if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") 730 if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture"))
730 { 731 {
731 m_log.InfoFormat( 732 m_log.InfoFormat(
732 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", 733 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
@@ -1647,10 +1648,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1647 1648
1648 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) 1649 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
1649 { 1650 {
1650 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); 1651 int responsecode;
1651 int responsecode = (int)responsedata["int_response_code"]; 1652 string responseString = String.Empty;
1652 string responseString = (string)responsedata["str_response_string"]; 1653 byte[] responseData = null;
1653 string contentType = (string)responsedata["content_type"]; 1654 string contentType;
1655
1656 if (responsedata == null)
1657 {
1658 responsecode = 500;
1659 responseString = "No response could be obtained";
1660 contentType = "text/plain";
1661 responsedata = new Hashtable();
1662 }
1663 else
1664 {
1665 try
1666 {
1667 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
1668 responsecode = (int)responsedata["int_response_code"];
1669 if (responsedata["bin_response_data"] != null)
1670 responseData = (byte[])responsedata["bin_response_data"];
1671 else
1672 responseString = (string)responsedata["str_response_string"];
1673 contentType = (string)responsedata["content_type"];
1674 if (responseString == null)
1675 responseString = String.Empty;
1676 }
1677 catch
1678 {
1679 responsecode = 500;
1680 responseString = "No response could be obtained";
1681 contentType = "text/plain";
1682 responsedata = new Hashtable();
1683 }
1684 }
1654 1685
1655 if (responsedata.ContainsKey("error_status_text")) 1686 if (responsedata.ContainsKey("error_status_text"))
1656 { 1687 {
@@ -1695,25 +1726,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1695 1726
1696 response.AddHeader("Content-Type", contentType); 1727 response.AddHeader("Content-Type", contentType);
1697 1728
1729 if (responsedata.ContainsKey("headers"))
1730 {
1731 Hashtable headerdata = (Hashtable)responsedata["headers"];
1732
1733 foreach (string header in headerdata.Keys)
1734 response.AddHeader(header, (string)headerdata[header]);
1735 }
1736
1698 byte[] buffer; 1737 byte[] buffer;
1699 1738
1700 if (!(contentType.Contains("image") 1739 if (responseData != null)
1701 || contentType.Contains("x-shockwave-flash")
1702 || contentType.Contains("application/x-oar")
1703 || contentType.Contains("application/vnd.ll.mesh")))
1704 { 1740 {
1705 // Text 1741 buffer = responseData;
1706 buffer = Encoding.UTF8.GetBytes(responseString);
1707 } 1742 }
1708 else 1743 else
1709 { 1744 {
1710 // Binary! 1745 if (!(contentType.Contains("image")
1711 buffer = Convert.FromBase64String(responseString); 1746 || contentType.Contains("x-shockwave-flash")
1712 } 1747 || contentType.Contains("application/x-oar")
1748 || contentType.Contains("application/vnd.ll.mesh")))
1749 {
1750 // Text
1751 buffer = Encoding.UTF8.GetBytes(responseString);
1752 }
1753 else
1754 {
1755 // Binary!
1756 buffer = Convert.FromBase64String(responseString);
1757 }
1713 1758
1714 response.SendChunked = false; 1759 response.SendChunked = false;
1715 response.ContentLength64 = buffer.Length; 1760 response.ContentLength64 = buffer.Length;
1716 response.ContentEncoding = Encoding.UTF8; 1761 response.ContentEncoding = Encoding.UTF8;
1762 }
1717 1763
1718 return buffer; 1764 return buffer;
1719 } 1765 }
@@ -1793,8 +1839,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1793 m_httpListener2.Start(64); 1839 m_httpListener2.Start(64);
1794 1840
1795 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events 1841 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
1796 m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); 1842// m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000);
1797 m_PollServiceManager.Start(); 1843 m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000);
1798 HTTPDRunning = true; 1844 HTTPDRunning = true;
1799 1845
1800 //HttpListenerContext context; 1846 //HttpListenerContext context;
@@ -1828,7 +1874,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1828 1874
1829 public void httpServerException(object source, Exception exception) 1875 public void httpServerException(object source, Exception exception)
1830 { 1876 {
1831 m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); 1877 if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException"))
1878 return;
1879 m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
1832 /* 1880 /*
1833 if (HTTPDRunning)// && NotSocketErrors > 5) 1881 if (HTTPDRunning)// && NotSocketErrors > 5)
1834 { 1882 {
@@ -1845,7 +1893,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1845 HTTPDRunning = false; 1893 HTTPDRunning = false;
1846 try 1894 try
1847 { 1895 {
1848 m_PollServiceManager.Stop(); 1896// m_PollServiceManager.Stop();
1849 1897
1850 m_httpListener2.ExceptionThrown -= httpServerException; 1898 m_httpListener2.ExceptionThrown -= httpServerException;
1851 //m_httpListener2.DisconnectHandler = null; 1899 //m_httpListener2.DisconnectHandler = null;