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