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 66d80cf..77fce9e 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(); |
@@ -642,7 +643,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
642 | // Every month or so this will wrap and give bad numbers, not really a problem | 643 | // Every month or so this will wrap and give bad numbers, not really a problem |
643 | // since its just for reporting | 644 | // since its just for reporting |
644 | int tickdiff = requestEndTick - requestStartTick; | 645 | int tickdiff = requestEndTick - requestStartTick; |
645 | if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") | 646 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) |
646 | { | 647 | { |
647 | m_log.InfoFormat( | 648 | m_log.InfoFormat( |
648 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", | 649 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", |
@@ -1529,10 +1530,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1529 | 1530 | ||
1530 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1531 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1531 | { | 1532 | { |
1532 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1533 | int responsecode; |
1533 | int responsecode = (int)responsedata["int_response_code"]; | 1534 | string responseString = String.Empty; |
1534 | string responseString = (string)responsedata["str_response_string"]; | 1535 | byte[] responseData = null; |
1535 | string contentType = (string)responsedata["content_type"]; | 1536 | string contentType; |
1537 | |||
1538 | if (responsedata == null) | ||
1539 | { | ||
1540 | responsecode = 500; | ||
1541 | responseString = "No response could be obtained"; | ||
1542 | contentType = "text/plain"; | ||
1543 | responsedata = new Hashtable(); | ||
1544 | } | ||
1545 | else | ||
1546 | { | ||
1547 | try | ||
1548 | { | ||
1549 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1550 | responsecode = (int)responsedata["int_response_code"]; | ||
1551 | if (responsedata["bin_response_data"] != null) | ||
1552 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1553 | else | ||
1554 | responseString = (string)responsedata["str_response_string"]; | ||
1555 | contentType = (string)responsedata["content_type"]; | ||
1556 | if (responseString == null) | ||
1557 | responseString = String.Empty; | ||
1558 | } | ||
1559 | catch | ||
1560 | { | ||
1561 | responsecode = 500; | ||
1562 | responseString = "No response could be obtained"; | ||
1563 | contentType = "text/plain"; | ||
1564 | responsedata = new Hashtable(); | ||
1565 | } | ||
1566 | } | ||
1536 | 1567 | ||
1537 | if (responsedata.ContainsKey("error_status_text")) | 1568 | if (responsedata.ContainsKey("error_status_text")) |
1538 | { | 1569 | { |
@@ -1577,25 +1608,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1577 | 1608 | ||
1578 | response.AddHeader("Content-Type", contentType); | 1609 | response.AddHeader("Content-Type", contentType); |
1579 | 1610 | ||
1611 | if (responsedata.ContainsKey("headers")) | ||
1612 | { | ||
1613 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1614 | |||
1615 | foreach (string header in headerdata.Keys) | ||
1616 | response.AddHeader(header, (string)headerdata[header]); | ||
1617 | } | ||
1618 | |||
1580 | byte[] buffer; | 1619 | byte[] buffer; |
1581 | 1620 | ||
1582 | if (!(contentType.Contains("image") | 1621 | if (responseData != null) |
1583 | || contentType.Contains("x-shockwave-flash") | ||
1584 | || contentType.Contains("application/x-oar") | ||
1585 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1586 | { | 1622 | { |
1587 | // Text | 1623 | buffer = responseData; |
1588 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1589 | } | 1624 | } |
1590 | else | 1625 | else |
1591 | { | 1626 | { |
1592 | // Binary! | 1627 | if (!(contentType.Contains("image") |
1593 | buffer = Convert.FromBase64String(responseString); | 1628 | || contentType.Contains("x-shockwave-flash") |
1594 | } | 1629 | || contentType.Contains("application/x-oar") |
1630 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1631 | { | ||
1632 | // Text | ||
1633 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1634 | } | ||
1635 | else | ||
1636 | { | ||
1637 | // Binary! | ||
1638 | buffer = Convert.FromBase64String(responseString); | ||
1639 | } | ||
1595 | 1640 | ||
1596 | response.SendChunked = false; | 1641 | response.SendChunked = false; |
1597 | response.ContentLength64 = buffer.Length; | 1642 | response.ContentLength64 = buffer.Length; |
1598 | response.ContentEncoding = Encoding.UTF8; | 1643 | response.ContentEncoding = Encoding.UTF8; |
1644 | } | ||
1599 | 1645 | ||
1600 | return buffer; | 1646 | return buffer; |
1601 | } | 1647 | } |
@@ -1675,7 +1721,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1675 | m_httpListener2.Start(64); | 1721 | m_httpListener2.Start(64); |
1676 | 1722 | ||
1677 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1723 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1678 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1724 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); |
1725 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); | ||
1679 | HTTPDRunning = true; | 1726 | HTTPDRunning = true; |
1680 | 1727 | ||
1681 | //HttpListenerContext context; | 1728 | //HttpListenerContext context; |
@@ -1709,7 +1756,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1709 | 1756 | ||
1710 | public void httpServerException(object source, Exception exception) | 1757 | public void httpServerException(object source, Exception exception) |
1711 | { | 1758 | { |
1712 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1759 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1760 | return; | ||
1761 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1713 | /* | 1762 | /* |
1714 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1763 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1715 | { | 1764 | { |