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 410a76a..3198891 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", |
@@ -1526,10 +1527,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1526 | 1527 | ||
1527 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1528 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1528 | { | 1529 | { |
1529 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1530 | int responsecode; |
1530 | int responsecode = (int)responsedata["int_response_code"]; | 1531 | string responseString = String.Empty; |
1531 | string responseString = (string)responsedata["str_response_string"]; | 1532 | byte[] responseData = null; |
1532 | string contentType = (string)responsedata["content_type"]; | 1533 | string contentType; |
1534 | |||
1535 | if (responsedata == null) | ||
1536 | { | ||
1537 | responsecode = 500; | ||
1538 | responseString = "No response could be obtained"; | ||
1539 | contentType = "text/plain"; | ||
1540 | responsedata = new Hashtable(); | ||
1541 | } | ||
1542 | else | ||
1543 | { | ||
1544 | try | ||
1545 | { | ||
1546 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1547 | responsecode = (int)responsedata["int_response_code"]; | ||
1548 | if (responsedata["bin_response_data"] != null) | ||
1549 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1550 | else | ||
1551 | responseString = (string)responsedata["str_response_string"]; | ||
1552 | contentType = (string)responsedata["content_type"]; | ||
1553 | if (responseString == null) | ||
1554 | responseString = String.Empty; | ||
1555 | } | ||
1556 | catch | ||
1557 | { | ||
1558 | responsecode = 500; | ||
1559 | responseString = "No response could be obtained"; | ||
1560 | contentType = "text/plain"; | ||
1561 | responsedata = new Hashtable(); | ||
1562 | } | ||
1563 | } | ||
1533 | 1564 | ||
1534 | if (responsedata.ContainsKey("error_status_text")) | 1565 | if (responsedata.ContainsKey("error_status_text")) |
1535 | { | 1566 | { |
@@ -1574,25 +1605,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1574 | 1605 | ||
1575 | response.AddHeader("Content-Type", contentType); | 1606 | response.AddHeader("Content-Type", contentType); |
1576 | 1607 | ||
1608 | if (responsedata.ContainsKey("headers")) | ||
1609 | { | ||
1610 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1611 | |||
1612 | foreach (string header in headerdata.Keys) | ||
1613 | response.AddHeader(header, (string)headerdata[header]); | ||
1614 | } | ||
1615 | |||
1577 | byte[] buffer; | 1616 | byte[] buffer; |
1578 | 1617 | ||
1579 | if (!(contentType.Contains("image") | 1618 | if (responseData != null) |
1580 | || contentType.Contains("x-shockwave-flash") | ||
1581 | || contentType.Contains("application/x-oar") | ||
1582 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1583 | { | 1619 | { |
1584 | // Text | 1620 | buffer = responseData; |
1585 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1586 | } | 1621 | } |
1587 | else | 1622 | else |
1588 | { | 1623 | { |
1589 | // Binary! | 1624 | if (!(contentType.Contains("image") |
1590 | buffer = Convert.FromBase64String(responseString); | 1625 | || contentType.Contains("x-shockwave-flash") |
1591 | } | 1626 | || contentType.Contains("application/x-oar") |
1627 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1628 | { | ||
1629 | // Text | ||
1630 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1631 | } | ||
1632 | else | ||
1633 | { | ||
1634 | // Binary! | ||
1635 | buffer = Convert.FromBase64String(responseString); | ||
1636 | } | ||
1592 | 1637 | ||
1593 | response.SendChunked = false; | 1638 | response.SendChunked = false; |
1594 | response.ContentLength64 = buffer.Length; | 1639 | response.ContentLength64 = buffer.Length; |
1595 | response.ContentEncoding = Encoding.UTF8; | 1640 | response.ContentEncoding = Encoding.UTF8; |
1641 | } | ||
1596 | 1642 | ||
1597 | return buffer; | 1643 | return buffer; |
1598 | } | 1644 | } |
@@ -1672,7 +1718,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1672 | m_httpListener2.Start(64); | 1718 | m_httpListener2.Start(64); |
1673 | 1719 | ||
1674 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1720 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1675 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1721 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); |
1722 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); | ||
1676 | HTTPDRunning = true; | 1723 | HTTPDRunning = true; |
1677 | 1724 | ||
1678 | //HttpListenerContext context; | 1725 | //HttpListenerContext context; |
@@ -1706,7 +1753,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1706 | 1753 | ||
1707 | public void httpServerException(object source, Exception exception) | 1754 | public void httpServerException(object source, Exception exception) |
1708 | { | 1755 | { |
1709 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1756 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1757 | return; | ||
1758 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1710 | /* | 1759 | /* |
1711 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1760 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1712 | { | 1761 | { |