diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 87 |
1 files changed, 68 insertions, 19 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index e1ae74e..7841f47 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -401,6 +401,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
401 | StreamReader reader = new StreamReader(requestStream, encoding); | 401 | StreamReader reader = new StreamReader(requestStream, encoding); |
402 | 402 | ||
403 | string requestBody = reader.ReadToEnd(); | 403 | string requestBody = reader.ReadToEnd(); |
404 | reader.Close(); | ||
404 | 405 | ||
405 | Hashtable keysvals = new Hashtable(); | 406 | Hashtable keysvals = new Hashtable(); |
406 | Hashtable headervals = new Hashtable(); | 407 | Hashtable headervals = new Hashtable(); |
@@ -740,7 +741,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
740 | // Every month or so this will wrap and give bad numbers, not really a problem | 741 | // Every month or so this will wrap and give bad numbers, not really a problem |
741 | // since its just for reporting | 742 | // since its just for reporting |
742 | int tickdiff = requestEndTick - requestStartTick; | 743 | int tickdiff = requestEndTick - requestStartTick; |
743 | if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") | 744 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) |
744 | { | 745 | { |
745 | m_log.InfoFormat( | 746 | m_log.InfoFormat( |
746 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", | 747 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", |
@@ -1675,10 +1676,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1675 | 1676 | ||
1676 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1677 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1677 | { | 1678 | { |
1678 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1679 | int responsecode; |
1679 | int responsecode = (int)responsedata["int_response_code"]; | 1680 | string responseString = String.Empty; |
1680 | string responseString = (string)responsedata["str_response_string"]; | 1681 | byte[] responseData = null; |
1681 | string contentType = (string)responsedata["content_type"]; | 1682 | string contentType; |
1683 | |||
1684 | if (responsedata == null) | ||
1685 | { | ||
1686 | responsecode = 500; | ||
1687 | responseString = "No response could be obtained"; | ||
1688 | contentType = "text/plain"; | ||
1689 | responsedata = new Hashtable(); | ||
1690 | } | ||
1691 | else | ||
1692 | { | ||
1693 | try | ||
1694 | { | ||
1695 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1696 | responsecode = (int)responsedata["int_response_code"]; | ||
1697 | if (responsedata["bin_response_data"] != null) | ||
1698 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1699 | else | ||
1700 | responseString = (string)responsedata["str_response_string"]; | ||
1701 | contentType = (string)responsedata["content_type"]; | ||
1702 | if (responseString == null) | ||
1703 | responseString = String.Empty; | ||
1704 | } | ||
1705 | catch | ||
1706 | { | ||
1707 | responsecode = 500; | ||
1708 | responseString = "No response could be obtained"; | ||
1709 | contentType = "text/plain"; | ||
1710 | responsedata = new Hashtable(); | ||
1711 | } | ||
1712 | } | ||
1682 | 1713 | ||
1683 | if (responsedata.ContainsKey("error_status_text")) | 1714 | if (responsedata.ContainsKey("error_status_text")) |
1684 | { | 1715 | { |
@@ -1723,25 +1754,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1723 | 1754 | ||
1724 | response.AddHeader("Content-Type", contentType); | 1755 | response.AddHeader("Content-Type", contentType); |
1725 | 1756 | ||
1757 | if (responsedata.ContainsKey("headers")) | ||
1758 | { | ||
1759 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1760 | |||
1761 | foreach (string header in headerdata.Keys) | ||
1762 | response.AddHeader(header, (string)headerdata[header]); | ||
1763 | } | ||
1764 | |||
1726 | byte[] buffer; | 1765 | byte[] buffer; |
1727 | 1766 | ||
1728 | if (!(contentType.Contains("image") | 1767 | if (responseData != null) |
1729 | || contentType.Contains("x-shockwave-flash") | ||
1730 | || contentType.Contains("application/x-oar") | ||
1731 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1732 | { | 1768 | { |
1733 | // Text | 1769 | buffer = responseData; |
1734 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1735 | } | 1770 | } |
1736 | else | 1771 | else |
1737 | { | 1772 | { |
1738 | // Binary! | 1773 | if (!(contentType.Contains("image") |
1739 | buffer = Convert.FromBase64String(responseString); | 1774 | || contentType.Contains("x-shockwave-flash") |
1740 | } | 1775 | || contentType.Contains("application/x-oar") |
1776 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1777 | { | ||
1778 | // Text | ||
1779 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1780 | } | ||
1781 | else | ||
1782 | { | ||
1783 | // Binary! | ||
1784 | buffer = Convert.FromBase64String(responseString); | ||
1785 | } | ||
1741 | 1786 | ||
1742 | response.SendChunked = false; | 1787 | response.SendChunked = false; |
1743 | response.ContentLength64 = buffer.Length; | 1788 | response.ContentLength64 = buffer.Length; |
1744 | response.ContentEncoding = Encoding.UTF8; | 1789 | response.ContentEncoding = Encoding.UTF8; |
1790 | } | ||
1745 | 1791 | ||
1746 | return buffer; | 1792 | return buffer; |
1747 | } | 1793 | } |
@@ -1822,7 +1868,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1822 | m_httpListener2.Start(64); | 1868 | m_httpListener2.Start(64); |
1823 | 1869 | ||
1824 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1870 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1825 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1871 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); |
1826 | m_PollServiceManager.Start(); | 1872 | m_PollServiceManager.Start(); |
1827 | HTTPDRunning = true; | 1873 | HTTPDRunning = true; |
1828 | 1874 | ||
@@ -1872,7 +1918,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1872 | 1918 | ||
1873 | public void httpServerException(object source, Exception exception) | 1919 | public void httpServerException(object source, Exception exception) |
1874 | { | 1920 | { |
1875 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1921 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1922 | return; | ||
1923 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1876 | /* | 1924 | /* |
1877 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1925 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1878 | { | 1926 | { |
@@ -1919,6 +1967,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1919 | 1967 | ||
1920 | public void RemoveHTTPHandler(string httpMethod, string path) | 1968 | public void RemoveHTTPHandler(string httpMethod, string path) |
1921 | { | 1969 | { |
1970 | if (path == null) return; // Caps module isn't loaded, tries to remove handler where path = null | ||
1922 | lock (m_HTTPHandlers) | 1971 | lock (m_HTTPHandlers) |
1923 | { | 1972 | { |
1924 | if (httpMethod != null && httpMethod.Length == 0) | 1973 | if (httpMethod != null && httpMethod.Length == 0) |