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 251a8ad..760d63a 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", |
@@ -1584,10 +1585,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1584 | 1585 | ||
1585 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1586 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1586 | { | 1587 | { |
1587 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1588 | int responsecode; |
1588 | int responsecode = (int)responsedata["int_response_code"]; | 1589 | string responseString = String.Empty; |
1589 | string responseString = (string)responsedata["str_response_string"]; | 1590 | byte[] responseData = null; |
1590 | string contentType = (string)responsedata["content_type"]; | 1591 | string contentType; |
1592 | |||
1593 | if (responsedata == null) | ||
1594 | { | ||
1595 | responsecode = 500; | ||
1596 | responseString = "No response could be obtained"; | ||
1597 | contentType = "text/plain"; | ||
1598 | responsedata = new Hashtable(); | ||
1599 | } | ||
1600 | else | ||
1601 | { | ||
1602 | try | ||
1603 | { | ||
1604 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1605 | responsecode = (int)responsedata["int_response_code"]; | ||
1606 | if (responsedata["bin_response_data"] != null) | ||
1607 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1608 | else | ||
1609 | responseString = (string)responsedata["str_response_string"]; | ||
1610 | contentType = (string)responsedata["content_type"]; | ||
1611 | if (responseString == null) | ||
1612 | responseString = String.Empty; | ||
1613 | } | ||
1614 | catch | ||
1615 | { | ||
1616 | responsecode = 500; | ||
1617 | responseString = "No response could be obtained"; | ||
1618 | contentType = "text/plain"; | ||
1619 | responsedata = new Hashtable(); | ||
1620 | } | ||
1621 | } | ||
1591 | 1622 | ||
1592 | if (responsedata.ContainsKey("error_status_text")) | 1623 | if (responsedata.ContainsKey("error_status_text")) |
1593 | { | 1624 | { |
@@ -1632,25 +1663,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1632 | 1663 | ||
1633 | response.AddHeader("Content-Type", contentType); | 1664 | response.AddHeader("Content-Type", contentType); |
1634 | 1665 | ||
1666 | if (responsedata.ContainsKey("headers")) | ||
1667 | { | ||
1668 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1669 | |||
1670 | foreach (string header in headerdata.Keys) | ||
1671 | response.AddHeader(header, (string)headerdata[header]); | ||
1672 | } | ||
1673 | |||
1635 | byte[] buffer; | 1674 | byte[] buffer; |
1636 | 1675 | ||
1637 | if (!(contentType.Contains("image") | 1676 | if (responseData != null) |
1638 | || contentType.Contains("x-shockwave-flash") | ||
1639 | || contentType.Contains("application/x-oar") | ||
1640 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1641 | { | 1677 | { |
1642 | // Text | 1678 | buffer = responseData; |
1643 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1644 | } | 1679 | } |
1645 | else | 1680 | else |
1646 | { | 1681 | { |
1647 | // Binary! | 1682 | if (!(contentType.Contains("image") |
1648 | buffer = Convert.FromBase64String(responseString); | 1683 | || contentType.Contains("x-shockwave-flash") |
1649 | } | 1684 | || contentType.Contains("application/x-oar") |
1685 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1686 | { | ||
1687 | // Text | ||
1688 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1689 | } | ||
1690 | else | ||
1691 | { | ||
1692 | // Binary! | ||
1693 | buffer = Convert.FromBase64String(responseString); | ||
1694 | } | ||
1650 | 1695 | ||
1651 | response.SendChunked = false; | 1696 | response.SendChunked = false; |
1652 | response.ContentLength64 = buffer.Length; | 1697 | response.ContentLength64 = buffer.Length; |
1653 | response.ContentEncoding = Encoding.UTF8; | 1698 | response.ContentEncoding = Encoding.UTF8; |
1699 | } | ||
1654 | 1700 | ||
1655 | return buffer; | 1701 | return buffer; |
1656 | } | 1702 | } |
@@ -1730,8 +1776,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1730 | m_httpListener2.Start(64); | 1776 | m_httpListener2.Start(64); |
1731 | 1777 | ||
1732 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1778 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1733 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1779 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); |
1734 | m_PollServiceManager.Start(); | 1780 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); |
1735 | HTTPDRunning = true; | 1781 | HTTPDRunning = true; |
1736 | 1782 | ||
1737 | //HttpListenerContext context; | 1783 | //HttpListenerContext context; |
@@ -1765,7 +1811,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1765 | 1811 | ||
1766 | public void httpServerException(object source, Exception exception) | 1812 | public void httpServerException(object source, Exception exception) |
1767 | { | 1813 | { |
1768 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1814 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1815 | return; | ||
1816 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1769 | /* | 1817 | /* |
1770 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1818 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1771 | { | 1819 | { |
@@ -1782,7 +1830,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1782 | HTTPDRunning = false; | 1830 | HTTPDRunning = false; |
1783 | try | 1831 | try |
1784 | { | 1832 | { |
1785 | m_PollServiceManager.Stop(); | 1833 | // m_PollServiceManager.Stop(); |
1786 | 1834 | ||
1787 | m_httpListener2.ExceptionThrown -= httpServerException; | 1835 | m_httpListener2.ExceptionThrown -= httpServerException; |
1788 | //m_httpListener2.DisconnectHandler = null; | 1836 | //m_httpListener2.DisconnectHandler = null; |