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 ff57422..b3e31a6 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -334,6 +334,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
334 | StreamReader reader = new StreamReader(requestStream, encoding); | 334 | StreamReader reader = new StreamReader(requestStream, encoding); |
335 | 335 | ||
336 | string requestBody = reader.ReadToEnd(); | 336 | string requestBody = reader.ReadToEnd(); |
337 | reader.Close(); | ||
337 | 338 | ||
338 | Hashtable keysvals = new Hashtable(); | 339 | Hashtable keysvals = new Hashtable(); |
339 | Hashtable headervals = new Hashtable(); | 340 | Hashtable headervals = new Hashtable(); |
@@ -648,7 +649,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
648 | // Every month or so this will wrap and give bad numbers, not really a problem | 649 | // Every month or so this will wrap and give bad numbers, not really a problem |
649 | // since its just for reporting | 650 | // since its just for reporting |
650 | int tickdiff = requestEndTick - requestStartTick; | 651 | int tickdiff = requestEndTick - requestStartTick; |
651 | if (tickdiff > 3000) | 652 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) |
652 | { | 653 | { |
653 | m_log.InfoFormat( | 654 | m_log.InfoFormat( |
654 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", | 655 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", |
@@ -1532,10 +1533,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1532 | 1533 | ||
1533 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1534 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1534 | { | 1535 | { |
1535 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1536 | int responsecode; |
1536 | int responsecode = (int)responsedata["int_response_code"]; | 1537 | string responseString = String.Empty; |
1537 | string responseString = (string)responsedata["str_response_string"]; | 1538 | byte[] responseData = null; |
1538 | string contentType = (string)responsedata["content_type"]; | 1539 | string contentType; |
1540 | |||
1541 | if (responsedata == null) | ||
1542 | { | ||
1543 | responsecode = 500; | ||
1544 | responseString = "No response could be obtained"; | ||
1545 | contentType = "text/plain"; | ||
1546 | responsedata = new Hashtable(); | ||
1547 | } | ||
1548 | else | ||
1549 | { | ||
1550 | try | ||
1551 | { | ||
1552 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1553 | responsecode = (int)responsedata["int_response_code"]; | ||
1554 | if (responsedata["bin_response_data"] != null) | ||
1555 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1556 | else | ||
1557 | responseString = (string)responsedata["str_response_string"]; | ||
1558 | contentType = (string)responsedata["content_type"]; | ||
1559 | if (responseString == null) | ||
1560 | responseString = String.Empty; | ||
1561 | } | ||
1562 | catch | ||
1563 | { | ||
1564 | responsecode = 500; | ||
1565 | responseString = "No response could be obtained"; | ||
1566 | contentType = "text/plain"; | ||
1567 | responsedata = new Hashtable(); | ||
1568 | } | ||
1569 | } | ||
1539 | 1570 | ||
1540 | if (responsedata.ContainsKey("error_status_text")) | 1571 | if (responsedata.ContainsKey("error_status_text")) |
1541 | { | 1572 | { |
@@ -1580,25 +1611,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1580 | 1611 | ||
1581 | response.AddHeader("Content-Type", contentType); | 1612 | response.AddHeader("Content-Type", contentType); |
1582 | 1613 | ||
1614 | if (responsedata.ContainsKey("headers")) | ||
1615 | { | ||
1616 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1617 | |||
1618 | foreach (string header in headerdata.Keys) | ||
1619 | response.AddHeader(header, (string)headerdata[header]); | ||
1620 | } | ||
1621 | |||
1583 | byte[] buffer; | 1622 | byte[] buffer; |
1584 | 1623 | ||
1585 | if (!(contentType.Contains("image") | 1624 | if (responseData != null) |
1586 | || contentType.Contains("x-shockwave-flash") | ||
1587 | || contentType.Contains("application/x-oar") | ||
1588 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1589 | { | 1625 | { |
1590 | // Text | 1626 | buffer = responseData; |
1591 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1592 | } | 1627 | } |
1593 | else | 1628 | else |
1594 | { | 1629 | { |
1595 | // Binary! | 1630 | if (!(contentType.Contains("image") |
1596 | buffer = Convert.FromBase64String(responseString); | 1631 | || contentType.Contains("x-shockwave-flash") |
1597 | } | 1632 | || contentType.Contains("application/x-oar") |
1633 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1634 | { | ||
1635 | // Text | ||
1636 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1637 | } | ||
1638 | else | ||
1639 | { | ||
1640 | // Binary! | ||
1641 | buffer = Convert.FromBase64String(responseString); | ||
1642 | } | ||
1598 | 1643 | ||
1599 | response.SendChunked = false; | 1644 | response.SendChunked = false; |
1600 | response.ContentLength64 = buffer.Length; | 1645 | response.ContentLength64 = buffer.Length; |
1601 | response.ContentEncoding = Encoding.UTF8; | 1646 | response.ContentEncoding = Encoding.UTF8; |
1647 | } | ||
1602 | 1648 | ||
1603 | return buffer; | 1649 | return buffer; |
1604 | } | 1650 | } |
@@ -1678,7 +1724,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1678 | m_httpListener2.Start(64); | 1724 | m_httpListener2.Start(64); |
1679 | 1725 | ||
1680 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1726 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1681 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1727 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); |
1728 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); | ||
1682 | HTTPDRunning = true; | 1729 | HTTPDRunning = true; |
1683 | 1730 | ||
1684 | //HttpListenerContext context; | 1731 | //HttpListenerContext context; |
@@ -1712,7 +1759,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1712 | 1759 | ||
1713 | public void httpServerException(object source, Exception exception) | 1760 | public void httpServerException(object source, Exception exception) |
1714 | { | 1761 | { |
1715 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1762 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1763 | return; | ||
1764 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1716 | /* | 1765 | /* |
1717 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1766 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1718 | { | 1767 | { |