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 2cd626f..93043cb 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", |
@@ -1476,10 +1477,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1476 | 1477 | ||
1477 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) | 1478 | internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) |
1478 | { | 1479 | { |
1479 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 1480 | int responsecode; |
1480 | int responsecode = (int)responsedata["int_response_code"]; | 1481 | string responseString = String.Empty; |
1481 | string responseString = (string)responsedata["str_response_string"]; | 1482 | byte[] responseData = null; |
1482 | string contentType = (string)responsedata["content_type"]; | 1483 | string contentType; |
1484 | |||
1485 | if (responsedata == null) | ||
1486 | { | ||
1487 | responsecode = 500; | ||
1488 | responseString = "No response could be obtained"; | ||
1489 | contentType = "text/plain"; | ||
1490 | responsedata = new Hashtable(); | ||
1491 | } | ||
1492 | else | ||
1493 | { | ||
1494 | try | ||
1495 | { | ||
1496 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | ||
1497 | responsecode = (int)responsedata["int_response_code"]; | ||
1498 | if (responsedata["bin_response_data"] != null) | ||
1499 | responseData = (byte[])responsedata["bin_response_data"]; | ||
1500 | else | ||
1501 | responseString = (string)responsedata["str_response_string"]; | ||
1502 | contentType = (string)responsedata["content_type"]; | ||
1503 | if (responseString == null) | ||
1504 | responseString = String.Empty; | ||
1505 | } | ||
1506 | catch | ||
1507 | { | ||
1508 | responsecode = 500; | ||
1509 | responseString = "No response could be obtained"; | ||
1510 | contentType = "text/plain"; | ||
1511 | responsedata = new Hashtable(); | ||
1512 | } | ||
1513 | } | ||
1483 | 1514 | ||
1484 | if (responsedata.ContainsKey("error_status_text")) | 1515 | if (responsedata.ContainsKey("error_status_text")) |
1485 | { | 1516 | { |
@@ -1524,25 +1555,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1524 | 1555 | ||
1525 | response.AddHeader("Content-Type", contentType); | 1556 | response.AddHeader("Content-Type", contentType); |
1526 | 1557 | ||
1558 | if (responsedata.ContainsKey("headers")) | ||
1559 | { | ||
1560 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
1561 | |||
1562 | foreach (string header in headerdata.Keys) | ||
1563 | response.AddHeader(header, (string)headerdata[header]); | ||
1564 | } | ||
1565 | |||
1527 | byte[] buffer; | 1566 | byte[] buffer; |
1528 | 1567 | ||
1529 | if (!(contentType.Contains("image") | 1568 | if (responseData != null) |
1530 | || contentType.Contains("x-shockwave-flash") | ||
1531 | || contentType.Contains("application/x-oar") | ||
1532 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1533 | { | 1569 | { |
1534 | // Text | 1570 | buffer = responseData; |
1535 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1536 | } | 1571 | } |
1537 | else | 1572 | else |
1538 | { | 1573 | { |
1539 | // Binary! | 1574 | if (!(contentType.Contains("image") |
1540 | buffer = Convert.FromBase64String(responseString); | 1575 | || contentType.Contains("x-shockwave-flash") |
1541 | } | 1576 | || contentType.Contains("application/x-oar") |
1577 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
1578 | { | ||
1579 | // Text | ||
1580 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
1581 | } | ||
1582 | else | ||
1583 | { | ||
1584 | // Binary! | ||
1585 | buffer = Convert.FromBase64String(responseString); | ||
1586 | } | ||
1542 | 1587 | ||
1543 | response.SendChunked = false; | 1588 | response.SendChunked = false; |
1544 | response.ContentLength64 = buffer.Length; | 1589 | response.ContentLength64 = buffer.Length; |
1545 | response.ContentEncoding = Encoding.UTF8; | 1590 | response.ContentEncoding = Encoding.UTF8; |
1591 | } | ||
1546 | 1592 | ||
1547 | return buffer; | 1593 | return buffer; |
1548 | } | 1594 | } |
@@ -1622,7 +1668,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1622 | m_httpListener2.Start(64); | 1668 | m_httpListener2.Start(64); |
1623 | 1669 | ||
1624 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1670 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1625 | m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | 1671 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); |
1672 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); | ||
1626 | HTTPDRunning = true; | 1673 | HTTPDRunning = true; |
1627 | 1674 | ||
1628 | //HttpListenerContext context; | 1675 | //HttpListenerContext context; |
@@ -1656,7 +1703,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1656 | 1703 | ||
1657 | public void httpServerException(object source, Exception exception) | 1704 | public void httpServerException(object source, Exception exception) |
1658 | { | 1705 | { |
1659 | m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); | 1706 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
1707 | return; | ||
1708 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | ||
1660 | /* | 1709 | /* |
1661 | if (HTTPDRunning)// && NotSocketErrors > 5) | 1710 | if (HTTPDRunning)// && NotSocketErrors > 5) |
1662 | { | 1711 | { |