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.cs412
1 files changed, 116 insertions, 296 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index f5addc8..9cc1d4c 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -408,7 +408,10 @@ namespace OpenSim.Framework.Servers.HttpServer
408 string uriString = request.RawUrl; 408 string uriString = request.RawUrl;
409 409
410// string reqnum = "unknown"; 410// string reqnum = "unknown";
411 int tickstart = Environment.TickCount; 411 int requestStartTick = Environment.TickCount;
412
413 // Will be adjusted later on.
414 int requestEndTick = requestStartTick;
412 415
413 IRequestHandler requestHandler = null; 416 IRequestHandler requestHandler = null;
414 417
@@ -433,6 +436,7 @@ namespace OpenSim.Framework.Servers.HttpServer
433 { 436 {
434 if (HandleAgentRequest(agentHandler, request, response)) 437 if (HandleAgentRequest(agentHandler, request, response))
435 { 438 {
439 requestEndTick = Environment.TickCount;
436 return; 440 return;
437 } 441 }
438 } 442 }
@@ -442,6 +446,7 @@ namespace OpenSim.Framework.Servers.HttpServer
442 446
443 string path = request.RawUrl; 447 string path = request.RawUrl;
444 string handlerKey = GetHandlerKey(request.HttpMethod, path); 448 string handlerKey = GetHandlerKey(request.HttpMethod, path);
449 byte[] buffer = null;
445 450
446 if (TryGetStreamHandler(handlerKey, out requestHandler)) 451 if (TryGetStreamHandler(handlerKey, out requestHandler))
447 { 452 {
@@ -450,9 +455,6 @@ namespace OpenSim.Framework.Servers.HttpServer
450 "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", 455 "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}",
451 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); 456 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description);
452 457
453 // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler.
454 byte[] buffer = null;
455
456 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. 458 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
457 459
458 if (requestHandler is IStreamedRequestHandler) 460 if (requestHandler is IStreamedRequestHandler)
@@ -507,8 +509,8 @@ namespace OpenSim.Framework.Servers.HttpServer
507 //m_log.Warn("[HTTP]: " + requestBody); 509 //m_log.Warn("[HTTP]: " + requestBody);
508 510
509 } 511 }
510 DoHTTPGruntWork(HTTPRequestHandler.Handle(path, keysvals), response); 512
511 return; 513 buffer = DoHTTPGruntWork(HTTPRequestHandler.Handle(path, keysvals), response);
512 } 514 }
513 else 515 else
514 { 516 {
@@ -521,133 +523,100 @@ namespace OpenSim.Framework.Servers.HttpServer
521 buffer = memoryStream.ToArray(); 523 buffer = memoryStream.ToArray();
522 } 524 }
523 } 525 }
524
525 request.InputStream.Close();
526
527 // HTTP IN support. The script engine takes it from here
528 // Nothing to worry about for us.
529 //
530 if (buffer == null)
531 return;
532
533 if (!response.SendChunked)
534 response.ContentLength64 = buffer.LongLength;
535
536 try
537 {
538 response.OutputStream.Write(buffer, 0, buffer.Length);
539 //response.OutputStream.Close();
540 }
541 catch (HttpListenerException)
542 {
543 m_log.WarnFormat("[BASE HTTP SERVER]: HTTP request abnormally terminated.");
544 }
545 //response.OutputStream.Close();
546 try
547 {
548 response.Send();
549 //response.FreeContext();
550 }
551 catch (SocketException e)
552 {
553 // This has to be here to prevent a Linux/Mono crash
554 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", e.Message), e);
555 }
556 catch (IOException e)
557 {
558 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}. ", e.Message), e);
559 }
560
561 return;
562 } 526 }
563 527 else
564 if (request.AcceptTypes != null && request.AcceptTypes.Length > 0)
565 { 528 {
566 foreach (string strAccept in request.AcceptTypes) 529 switch (request.ContentType)
567 { 530 {
568 if (strAccept.Contains("application/llsd+xml") || 531 case null:
569 strAccept.Contains("application/llsd+json")) 532 case "text/html":
570 { 533
571 if (DebugLevel >= 1)
572 m_log.DebugFormat(
573 "[BASE HTTP SERVER]: Found application/llsd+xml accept header handler for {0} {1}",
574 request.HttpMethod, request.Url.PathAndQuery);
575
576 HandleLLSDRequests(request, response);
577 return;
578 }
579 }
580 }
581
582 switch (request.ContentType)
583 {
584 case null:
585 case "text/html":
586
587 if (DebugLevel >= 1)
588 m_log.DebugFormat(
589 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
590 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
591
592 HandleHTTPRequest(request, response);
593 return;
594
595 case "application/llsd+xml":
596 case "application/xml+llsd":
597 case "application/llsd+json":
598
599 if (DebugLevel >= 1)
600 m_log.DebugFormat(
601 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
602 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
603
604 HandleLLSDRequests(request, response);
605 return;
606
607 case "text/xml":
608 case "application/xml":
609 case "application/json":
610 default:
611 //m_log.Info("[Debug BASE HTTP SERVER]: in default handler");
612 // Point of note.. the DoWeHaveA methods check for an EXACT path
613 // if (request.RawUrl.Contains("/CAPS/EQG"))
614 // {
615 // int i = 1;
616 // }
617 //m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler");
618 if (DoWeHaveALLSDHandler(request.RawUrl))
619 {
620 if (DebugLevel >= 1) 534 if (DebugLevel >= 1)
621 m_log.DebugFormat( 535 m_log.DebugFormat(
622 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 536 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
623 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 537 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
624 538
625 HandleLLSDRequests(request, response); 539 buffer = HandleHTTPRequest(request, response);
626 return; 540 break;
627 } 541
628 542 case "application/llsd+xml":
629// m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); 543 case "application/xml+llsd":
630 if (DoWeHaveAHTTPHandler(request.RawUrl)) 544 case "application/llsd+json":
631 { 545
632 if (DebugLevel >= 1) 546 if (DebugLevel >= 1)
633 m_log.DebugFormat( 547 m_log.DebugFormat(
634 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 548 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
635 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 549 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
550
551 buffer = HandleLLSDRequests(request, response);
552 break;
553
554 case "text/xml":
555 case "application/xml":
556 case "application/json":
557 default:
558 //m_log.Info("[Debug BASE HTTP SERVER]: in default handler");
559 // Point of note.. the DoWeHaveA methods check for an EXACT path
560 // if (request.RawUrl.Contains("/CAPS/EQG"))
561 // {
562 // int i = 1;
563 // }
564 //m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler");
565 if (DoWeHaveALLSDHandler(request.RawUrl))
566 {
567 if (DebugLevel >= 1)
568 m_log.DebugFormat(
569 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
570 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
571
572 buffer = HandleLLSDRequests(request, response);
573 }
574 // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
575 else if (DoWeHaveAHTTPHandler(request.RawUrl))
576 {
577 if (DebugLevel >= 1)
578 m_log.DebugFormat(
579 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
580 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
581
582 buffer = HandleHTTPRequest(request, response);
583 }
584 else
585 {
586
587 if (DebugLevel >= 1)
588 m_log.DebugFormat(
589 "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}",
590 request.HttpMethod, request.Url.PathAndQuery);
591
592 // generic login request.
593 buffer = HandleXmlRpcRequests(request, response);
594 }
595
596 break;
597 }
598 }
636 599
637 HandleHTTPRequest(request, response); 600 request.InputStream.Close();
638 return;
639 }
640
641 if (DebugLevel >= 1)
642 m_log.DebugFormat(
643 "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}",
644 request.HttpMethod, request.Url.PathAndQuery);
645 601
646 // generic login request. 602 if (buffer != null)
647 HandleXmlRpcRequests(request, response); 603 {
604 if (!response.SendChunked)
605 response.ContentLength64 = buffer.LongLength;
648 606
649 return; 607 response.OutputStream.Write(buffer, 0, buffer.Length);
650 } 608 }
609
610 // Do not include the time taken to actually send the response to the caller in the measurement
611 // time. This is to avoid logging when it's the client that is slow to process rather than the
612 // server
613 requestEndTick = Environment.TickCount;
614
615 response.Send();
616
617 //response.OutputStream.Close();
618
619 //response.FreeContext();
651 } 620 }
652 catch (SocketException e) 621 catch (SocketException e)
653 { 622 {
@@ -672,8 +641,8 @@ namespace OpenSim.Framework.Servers.HttpServer
672 finally 641 finally
673 { 642 {
674 // 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
675 // since its just for reporting, tickdiff limit can be adjusted 644 // since its just for reporting
676 int tickdiff = Environment.TickCount - tickstart; 645 int tickdiff = requestEndTick - requestStartTick;
677 if (tickdiff > 3000) 646 if (tickdiff > 3000)
678 { 647 {
679 m_log.InfoFormat( 648 m_log.InfoFormat(
@@ -805,7 +774,7 @@ namespace OpenSim.Framework.Servers.HttpServer
805 /// </summary> 774 /// </summary>
806 /// <param name="request"></param> 775 /// <param name="request"></param>
807 /// <param name="response"></param> 776 /// <param name="response"></param>
808 private void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) 777 private byte[] HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response)
809 { 778 {
810 Stream requestStream = request.InputStream; 779 Stream requestStream = request.InputStream;
811 780
@@ -817,7 +786,7 @@ namespace OpenSim.Framework.Servers.HttpServer
817 requestStream.Close(); 786 requestStream.Close();
818 //m_log.Debug(requestBody); 787 //m_log.Debug(requestBody);
819 requestBody = requestBody.Replace("<base64></base64>", ""); 788 requestBody = requestBody.Replace("<base64></base64>", "");
820 string responseString = String.Empty; 789 string responseString = null;
821 XmlRpcRequest xmlRprcRequest = null; 790 XmlRpcRequest xmlRprcRequest = null;
822 791
823 try 792 try
@@ -895,6 +864,7 @@ namespace OpenSim.Framework.Servers.HttpServer
895 String.Format("Requested method [{0}] not found", methodName)); 864 String.Format("Requested method [{0}] not found", methodName));
896 } 865 }
897 866
867 response.ContentType = "text/xml";
898 responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); 868 responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
899 } 869 }
900 else 870 else
@@ -904,82 +874,25 @@ namespace OpenSim.Framework.Servers.HttpServer
904 response.StatusCode = 404; 874 response.StatusCode = 404;
905 response.StatusDescription = "Not Found"; 875 response.StatusDescription = "Not Found";
906 response.ProtocolVersion = "HTTP/1.0"; 876 response.ProtocolVersion = "HTTP/1.0";
907 byte[] buf = Encoding.UTF8.GetBytes("Not found"); 877 responseString = "Not found";
908 response.KeepAlive = false; 878 response.KeepAlive = false;
909 879
910 m_log.ErrorFormat( 880 m_log.ErrorFormat(
911 "[BASE HTTP SERVER]: Handler not found for http request {0} {1}", 881 "[BASE HTTP SERVER]: Handler not found for http request {0} {1}",
912 request.HttpMethod, request.Url.PathAndQuery); 882 request.HttpMethod, request.Url.PathAndQuery);
913
914 response.SendChunked = false;
915 response.ContentLength64 = buf.Length;
916 response.ContentEncoding = Encoding.UTF8;
917
918 try
919 {
920 response.OutputStream.Write(buf, 0, buf.Length);
921 }
922 catch (Exception ex)
923 {
924 m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
925 }
926 finally
927 {
928 try
929 {
930 response.Send();
931 //response.FreeContext();
932 }
933 catch (SocketException e)
934 {
935 // This has to be here to prevent a Linux/Mono crash
936 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", e.Message), e);
937 }
938 catch (IOException e)
939 {
940 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0} ", e.Message), e);
941 }
942 }
943 return;
944 //responseString = "Error";
945 } 883 }
946 } 884 }
947 885
948 response.ContentType = "text/xml";
949
950 byte[] buffer = Encoding.UTF8.GetBytes(responseString); 886 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
951 887
952 response.SendChunked = false; 888 response.SendChunked = false;
953 response.ContentLength64 = buffer.Length; 889 response.ContentLength64 = buffer.Length;
954 response.ContentEncoding = Encoding.UTF8; 890 response.ContentEncoding = Encoding.UTF8;
955 try 891
956 { 892 return buffer;
957 response.OutputStream.Write(buffer, 0, buffer.Length);
958 }
959 catch (Exception ex)
960 {
961 m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
962 }
963 finally
964 {
965 try
966 {
967 response.Send();
968 //response.FreeContext();
969 }
970 catch (SocketException e)
971 {
972 // This has to be here to prevent a Linux/Mono crash
973 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", e.Message), e);
974 }
975 catch (IOException e)
976 {
977 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0} ", e.Message), e);
978 }
979 }
980 } 893 }
981 894
982 private void HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response) 895 private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response)
983 { 896 {
984 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); 897 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
985 Stream requestStream = request.InputStream; 898 Stream requestStream = request.InputStream;
@@ -1065,34 +978,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1065 response.ContentEncoding = Encoding.UTF8; 978 response.ContentEncoding = Encoding.UTF8;
1066 response.KeepAlive = true; 979 response.KeepAlive = true;
1067 980
1068 try 981 return buffer;
1069 {
1070 response.OutputStream.Write(buffer, 0, buffer.Length);
1071 }
1072 catch (Exception ex)
1073 {
1074 m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
1075 }
1076 finally
1077 {
1078 //response.OutputStream.Close();
1079 try
1080 {
1081 response.Send();
1082 response.OutputStream.Flush();
1083 //response.FreeContext();
1084 //response.OutputStream.Close();
1085 }
1086 catch (IOException e)
1087 {
1088 m_log.Warn(String.Format("[BASE HTTP SERVER]: LLSD IOException {0} ", e.Message), e);
1089 }
1090 catch (SocketException e)
1091 {
1092 // This has to be here to prevent a Linux/Mono crash
1093 m_log.Warn(String.Format("[BASE HTTP SERVER]: LLSD issue {0}.\nNOTE: this may be spurious on Linux. ", e.Message), e);
1094 }
1095 }
1096 } 982 }
1097 983
1098 private byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, OSD llsdResponse) 984 private byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, OSD llsdResponse)
@@ -1357,7 +1243,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1357 1243
1358 } 1244 }
1359 1245
1360 public void HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) 1246 public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response)
1361 { 1247 {
1362// m_log.DebugFormat( 1248// m_log.DebugFormat(
1363// "[BASE HTTP SERVER]: HandleHTTPRequest for request to {0}, method {1}", 1249// "[BASE HTTP SERVER]: HandleHTTPRequest for request to {0}, method {1}",
@@ -1367,15 +1253,14 @@ namespace OpenSim.Framework.Servers.HttpServer
1367 { 1253 {
1368 case "OPTIONS": 1254 case "OPTIONS":
1369 response.StatusCode = (int)OSHttpStatusCode.SuccessOk; 1255 response.StatusCode = (int)OSHttpStatusCode.SuccessOk;
1370 return; 1256 return null;
1371 1257
1372 default: 1258 default:
1373 HandleContentVerbs(request, response); 1259 return HandleContentVerbs(request, response);
1374 return;
1375 } 1260 }
1376 } 1261 }
1377 1262
1378 private void HandleContentVerbs(OSHttpRequest request, OSHttpResponse response) 1263 private byte[] HandleContentVerbs(OSHttpRequest request, OSHttpResponse response)
1379 { 1264 {
1380// m_log.DebugFormat("[BASE HTTP SERVER]: HandleContentVerbs for request to {0}", request.RawUrl); 1265// m_log.DebugFormat("[BASE HTTP SERVER]: HandleContentVerbs for request to {0}", request.RawUrl);
1381 1266
@@ -1391,6 +1276,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1391 // to display the form, or process it. 1276 // to display the form, or process it.
1392 // a better way would be nifty. 1277 // a better way would be nifty.
1393 1278
1279 byte[] buffer;
1280
1394 Stream requestStream = request.InputStream; 1281 Stream requestStream = request.InputStream;
1395 1282
1396 Encoding encoding = Encoding.UTF8; 1283 Encoding encoding = Encoding.UTF8;
@@ -1451,14 +1338,14 @@ namespace OpenSim.Framework.Servers.HttpServer
1451 if (foundHandler) 1338 if (foundHandler)
1452 { 1339 {
1453 Hashtable responsedata1 = requestprocessor(keysvals); 1340 Hashtable responsedata1 = requestprocessor(keysvals);
1454 DoHTTPGruntWork(responsedata1,response); 1341 buffer = DoHTTPGruntWork(responsedata1,response);
1455 1342
1456 //SendHTML500(response); 1343 //SendHTML500(response);
1457 } 1344 }
1458 else 1345 else
1459 { 1346 {
1460// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found"); 1347// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found");
1461 SendHTML404(response, host); 1348 buffer = SendHTML404(response, host);
1462 } 1349 }
1463 } 1350 }
1464 else 1351 else
@@ -1468,16 +1355,18 @@ namespace OpenSim.Framework.Servers.HttpServer
1468 if (foundHandler) 1355 if (foundHandler)
1469 { 1356 {
1470 Hashtable responsedata2 = requestprocessor(keysvals); 1357 Hashtable responsedata2 = requestprocessor(keysvals);
1471 DoHTTPGruntWork(responsedata2, response); 1358 buffer = DoHTTPGruntWork(responsedata2, response);
1472 1359
1473 //SendHTML500(response); 1360 //SendHTML500(response);
1474 } 1361 }
1475 else 1362 else
1476 { 1363 {
1477// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2"); 1364// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2");
1478 SendHTML404(response, host); 1365 buffer = SendHTML404(response, host);
1479 } 1366 }
1480 } 1367 }
1368
1369 return buffer;
1481 } 1370 }
1482 1371
1483 private bool TryGetHTTPHandlerPathBased(string path, out GenericHTTPMethod httpHandler) 1372 private bool TryGetHTTPHandlerPathBased(string path, out GenericHTTPMethod httpHandler)
@@ -1545,7 +1434,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1545 } 1434 }
1546 } 1435 }
1547 1436
1548 internal void DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) 1437 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
1549 { 1438 {
1550 int responsecode; 1439 int responsecode;
1551 string responseString; 1440 string responseString;
@@ -1639,38 +1528,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1639 response.ContentLength64 = buffer.Length; 1528 response.ContentLength64 = buffer.Length;
1640 response.ContentEncoding = Encoding.UTF8; 1529 response.ContentEncoding = Encoding.UTF8;
1641 1530
1642 try 1531 return buffer;
1643 {
1644 response.OutputStream.Write(buffer, 0, buffer.Length);
1645 }
1646 catch (Exception ex)
1647 {
1648 m_log.Warn("[HTTPD]: Error - " + ex.Message);
1649 }
1650 finally
1651 {
1652 //response.OutputStream.Close();
1653 try
1654 {
1655 response.OutputStream.Flush();
1656 response.Send();
1657
1658 //if (!response.KeepAlive && response.ReuseContext)
1659 // response.FreeContext();
1660 }
1661 catch (SocketException e)
1662 {
1663 // This has to be here to prevent a Linux/Mono crash
1664 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", e.Message), e);
1665 }
1666 catch (IOException e)
1667 {
1668 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0} ", e.Message), e);
1669 }
1670 }
1671 } 1532 }
1672 1533
1673 public void SendHTML404(OSHttpResponse response, string host) 1534 public byte[] SendHTML404(OSHttpResponse response, string host)
1674 { 1535 {
1675 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s 1536 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s
1676 response.StatusCode = 404; 1537 response.StatusCode = 404;
@@ -1683,31 +1544,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1683 response.ContentLength64 = buffer.Length; 1544 response.ContentLength64 = buffer.Length;
1684 response.ContentEncoding = Encoding.UTF8; 1545 response.ContentEncoding = Encoding.UTF8;
1685 1546
1686 try 1547 return buffer;
1687 {
1688 response.OutputStream.Write(buffer, 0, buffer.Length);
1689 }
1690 catch (Exception ex)
1691 {
1692 m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
1693 }
1694 finally
1695 {
1696 //response.OutputStream.Close();
1697 try
1698 {
1699 response.Send();
1700 //response.FreeContext();
1701 }
1702 catch (SocketException e)
1703 {
1704 // This has to be here to prevent a Linux/Mono crash
1705 m_log.Warn(String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", e.Message), e);
1706 }
1707 }
1708 } 1548 }
1709 1549
1710 public void SendHTML500(OSHttpResponse response) 1550 public byte[] SendHTML500(OSHttpResponse response)
1711 { 1551 {
1712 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s 1552 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s
1713 response.StatusCode = (int)OSHttpStatusCode.SuccessOk; 1553 response.StatusCode = (int)OSHttpStatusCode.SuccessOk;
@@ -1719,28 +1559,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1719 response.SendChunked = false; 1559 response.SendChunked = false;
1720 response.ContentLength64 = buffer.Length; 1560 response.ContentLength64 = buffer.Length;
1721 response.ContentEncoding = Encoding.UTF8; 1561 response.ContentEncoding = Encoding.UTF8;
1722 try 1562
1723 { 1563 return buffer;
1724 response.OutputStream.Write(buffer, 0, buffer.Length);
1725 }
1726 catch (Exception ex)
1727 {
1728 m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
1729 }
1730 finally
1731 {
1732 //response.OutputStream.Close();
1733 try
1734 {
1735 response.Send();
1736 //response.FreeContext();
1737 }
1738 catch (SocketException e)
1739 {
1740 // This has to be here to prevent a Linux/Mono crash
1741 m_log.Warn(String.Format("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", e.Message), e);
1742 }
1743 }
1744 } 1564 }
1745 1565
1746 public void Start() 1566 public void Start()