diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 86 |
1 files changed, 67 insertions, 19 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index c4e569d..f4b4156 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", |
@@ -1661,10 +1662,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1661 | 1662 | ||
1662 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1663 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1663 | { | 1664 | { |
1664 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1665 | int responsecode; |
1665 | int responsecode = (int)responsedata["int_response_code"]; | 1666 | string responseString = String.Empty; |
1666 | string responseString = (string)responsedata["str_response_string"]; | 1667 | byte[] responseData = null; |
1667 | string contentType = (string)responsedata["content_type"]; | 1668 | string contentType; |
1669 | |||
1670 | if (responsedata == null) | ||
1671 | { | ||
1672 | responsecode = 500; | ||
1673 | responseString = "No response could be obtained"; | ||
1674 | contentType = "text/plain"; | ||
1675 | responsedata = new Hashtable(); | ||
1676 | } | ||
1677 | else | ||
1678 | { | ||
1679 | try | ||
1680 | { | ||
1681 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1682 | responsecode = (int)responsedata["int_response_code"]; | ||
1683 | if (responsedata["bin_response_data"] != null) | ||
1684 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1685 | else | ||
1686 | responseString = (string)responsedata["str_response_string"]; | ||
1687 | contentType = (string)responsedata["content_type"]; | ||
1688 | if (responseString == null) | ||
1689 | responseString = String.Empty; | ||
1690 | } | ||
1691 | catch | ||
1692 | { | ||
1693 | responsecode = 500; | ||
1694 | responseString = "No response could be obtained"; | ||
1695 | contentType = "text/plain"; | ||
1696 | responsedata = new Hashtable(); | ||
1697 | } | ||
1698 | } | ||
1668 | 1699 | ||
1669 | if (responsedata.ContainsKey("error_status_text")) | 1700 | if (responsedata.ContainsKey("error_status_text")) |
1670 | { | 1701 | { |
@@ -1709,25 +1740,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1709 | 1740 | ||
1710 | response.AddHeader("Content-Type", contentType); | 1741 | response.AddHeader("Content-Type", contentType); |
1711 | 1742 | ||
1743 | if (responsedata.ContainsKey("headers")) | ||
1744 | { | ||
1745 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1746 | |||
1747 | foreach (string header in headerdata.Keys) | ||
1748 | response.AddHeader(header, (string)headerdata[header]); | ||
1749 | } | ||
1750 | |||
1712 | byte[] buffer; | 1751 | byte[] buffer; |
1713 | 1752 | ||
1714 | if (!(contentType.Contains("image") | 1753 | if (responseData != null) |
1715 | || contentType.Contains("x-shockwave-flash") | ||
1716 | || contentType.Contains("application/x-oar") | ||
1717 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1718 | { | 1754 | { |
1719 | // Text | 1755 | buffer = responseData; |
1720 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1721 | } | 1756 | } |
1722 | else | 1757 | else |
1723 | { | 1758 | { |
1724 | // Binary! | 1759 | if (!(contentType.Contains("image") |
1725 | buffer = Convert.FromBase64String(responseString); | 1760 | || contentType.Contains("x-shockwave-flash") |
1726 | } | 1761 | || contentType.Contains("application/x-oar") |
1762 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1763 | { | ||
1764 | // Text | ||
1765 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1766 | } | ||
1767 | else | ||
1768 | { | ||
1769 | // Binary! | ||
1770 | buffer = Convert.FromBase64String(responseString); | ||
1771 | } | ||
1727 | 1772 | ||
1728 | response.SendChunked = false; | 1773 | response.SendChunked = false; |
1729 | response.ContentLength64 = buffer.Length; | 1774 | response.ContentLength64 = buffer.Length; |
1730 | response.ContentEncoding = Encoding.UTF8; | 1775 | response.ContentEncoding = Encoding.UTF8; |
1776 | } | ||
1731 | 1777 | ||
1732 | return buffer; | 1778 | return buffer; |
1733 | } | 1779 | } |
@@ -1808,7 +1854,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1808 | m_httpListener2.Start(64); | 1854 | m_httpListener2.Start(64); |
1809 | 1855 | ||
1810 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1856 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1811 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1857 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); |
1812 | m_PollServiceManager.Start(); | 1858 | m_PollServiceManager.Start(); |
1813 | HTTPDRunning = true; | 1859 | HTTPDRunning = true; |
1814 | 1860 | ||
@@ -1858,7 +1904,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1858 | 1904 | ||
1859 | public void httpServerException(object source, Exception exception) | 1905 | public void httpServerException(object source, Exception exception) |
1860 | { | 1906 | { |
1861 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1907 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1908 | return; | ||
1909 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1862 | /* | 1910 | /* |
1863 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1911 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1864 | { | 1912 | { |