diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 90 |
1 files changed, 69 insertions, 21 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 96a030b..74954cc 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(); |
@@ -736,7 +737,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
736 | // Every month or so this will wrap and give bad numbers, not really a problem | 737 | // Every month or so this will wrap and give bad numbers, not really a problem |
737 | // since its just for reporting | 738 | // since its just for reporting |
738 | int tickdiff = requestEndTick - requestStartTick; | 739 | int tickdiff = requestEndTick - requestStartTick; |
739 | if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") | 740 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) |
740 | { | 741 | { |
741 | m_log.InfoFormat( | 742 | m_log.InfoFormat( |
742 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", | 743 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", |
@@ -1657,10 +1658,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1657 | 1658 | ||
1658 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1659 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1659 | { | 1660 | { |
1660 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1661 | int responsecode; |
1661 | int responsecode = (int)responsedata["int_response_code"]; | 1662 | string responseString = String.Empty; |
1662 | string responseString = (string)responsedata["str_response_string"]; | 1663 | byte[] responseData = null; |
1663 | string contentType = (string)responsedata["content_type"]; | 1664 | string contentType; |
1665 | |||
1666 | if (responsedata == null) | ||
1667 | { | ||
1668 | responsecode = 500; | ||
1669 | responseString = "No response could be obtained"; | ||
1670 | contentType = "text/plain"; | ||
1671 | responsedata = new Hashtable(); | ||
1672 | } | ||
1673 | else | ||
1674 | { | ||
1675 | try | ||
1676 | { | ||
1677 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1678 | responsecode = (int)responsedata["int_response_code"]; | ||
1679 | if (responsedata["bin_response_data"] != null) | ||
1680 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1681 | else | ||
1682 | responseString = (string)responsedata["str_response_string"]; | ||
1683 | contentType = (string)responsedata["content_type"]; | ||
1684 | if (responseString == null) | ||
1685 | responseString = String.Empty; | ||
1686 | } | ||
1687 | catch | ||
1688 | { | ||
1689 | responsecode = 500; | ||
1690 | responseString = "No response could be obtained"; | ||
1691 | contentType = "text/plain"; | ||
1692 | responsedata = new Hashtable(); | ||
1693 | } | ||
1694 | } | ||
1664 | 1695 | ||
1665 | if (responsedata.ContainsKey("error_status_text")) | 1696 | if (responsedata.ContainsKey("error_status_text")) |
1666 | { | 1697 | { |
@@ -1705,25 +1736,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1705 | 1736 | ||
1706 | response.AddHeader("Content-Type", contentType); | 1737 | response.AddHeader("Content-Type", contentType); |
1707 | 1738 | ||
1739 | if (responsedata.ContainsKey("headers")) | ||
1740 | { | ||
1741 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1742 | |||
1743 | foreach (string header in headerdata.Keys) | ||
1744 | response.AddHeader(header, (string)headerdata[header]); | ||
1745 | } | ||
1746 | |||
1708 | byte[] buffer; | 1747 | byte[] buffer; |
1709 | 1748 | ||
1710 | if (!(contentType.Contains("image") | 1749 | if (responseData != null) |
1711 | || contentType.Contains("x-shockwave-flash") | ||
1712 | || contentType.Contains("application/x-oar") | ||
1713 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1714 | { | 1750 | { |
1715 | // Text | 1751 | buffer = responseData; |
1716 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1717 | } | 1752 | } |
1718 | else | 1753 | else |
1719 | { | 1754 | { |
1720 | // Binary! | 1755 | if (!(contentType.Contains("image") |
1721 | buffer = Convert.FromBase64String(responseString); | 1756 | || contentType.Contains("x-shockwave-flash") |
1722 | } | 1757 | || contentType.Contains("application/x-oar") |
1758 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1759 | { | ||
1760 | // Text | ||
1761 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1762 | } | ||
1763 | else | ||
1764 | { | ||
1765 | // Binary! | ||
1766 | buffer = Convert.FromBase64String(responseString); | ||
1767 | } | ||
1723 | 1768 | ||
1724 | response.SendChunked = false; | 1769 | response.SendChunked = false; |
1725 | response.ContentLength64 = buffer.Length; | 1770 | response.ContentLength64 = buffer.Length; |
1726 | response.ContentEncoding = Encoding.UTF8; | 1771 | response.ContentEncoding = Encoding.UTF8; |
1772 | } | ||
1727 | 1773 | ||
1728 | return buffer; | 1774 | return buffer; |
1729 | } | 1775 | } |
@@ -1804,8 +1850,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1804 | m_httpListener2.Start(64); | 1850 | m_httpListener2.Start(64); |
1805 | 1851 | ||
1806 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1852 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1807 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1853 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); |
1808 | m_PollServiceManager.Start(); | 1854 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); |
1809 | HTTPDRunning = true; | 1855 | HTTPDRunning = true; |
1810 | 1856 | ||
1811 | //HttpListenerContext context; | 1857 | //HttpListenerContext context; |
@@ -1839,7 +1885,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1839 | 1885 | ||
1840 | public void httpServerException(object source, Exception exception) | 1886 | public void httpServerException(object source, Exception exception) |
1841 | { | 1887 | { |
1842 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1888 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1889 | return; | ||
1890 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1843 | /* | 1891 | /* |
1844 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1892 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1845 | { | 1893 | { |
@@ -1856,7 +1904,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1856 | HTTPDRunning = false; | 1904 | HTTPDRunning = false; |
1857 | try | 1905 | try |
1858 | { | 1906 | { |
1859 | m_PollServiceManager.Stop(); | 1907 | // m_PollServiceManager.Stop(); |
1860 | 1908 | ||
1861 | m_httpListener2.ExceptionThrown -= httpServerException; | 1909 | m_httpListener2.ExceptionThrown -= httpServerException; |
1862 | //m_httpListener2.DisconnectHandler = null; | 1910 | //m_httpListener2.DisconnectHandler = null; |