diff options
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 74 |
1 files changed, 67 insertions, 7 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 98e7f0e..878e2fd 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -457,6 +457,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
457 | // This has to be here to prevent a Linux/Mono crash | 457 | // This has to be here to prevent a Linux/Mono crash |
458 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); | 458 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); |
459 | } | 459 | } |
460 | catch (IOException e) | ||
461 | { | ||
462 | m_log.Warn("[BASE HTTP SERVER] XmlRpcRequest issue: " + e.Message); | ||
463 | } | ||
460 | return; | 464 | return; |
461 | } | 465 | } |
462 | 466 | ||
@@ -464,7 +468,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
464 | { | 468 | { |
465 | foreach (string strAccept in request.AcceptTypes) | 469 | foreach (string strAccept in request.AcceptTypes) |
466 | { | 470 | { |
467 | if (strAccept.Contains("application/llsd+xml")) | 471 | if (strAccept.Contains("application/llsd+xml") || |
472 | strAccept.Contains("application/llsd+json")) | ||
468 | { | 473 | { |
469 | //m_log.Info("[Debug BASE HTTP SERVER]: Found an application/llsd+xml accept header"); | 474 | //m_log.Info("[Debug BASE HTTP SERVER]: Found an application/llsd+xml accept header"); |
470 | HandleLLSDRequests(request, response); | 475 | HandleLLSDRequests(request, response); |
@@ -483,12 +488,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
483 | 488 | ||
484 | case "application/llsd+xml": | 489 | case "application/llsd+xml": |
485 | case "application/xml+llsd": | 490 | case "application/xml+llsd": |
491 | case "application/llsd+json": | ||
486 | //m_log.Info("[Debug BASE HTTP SERVER]: found a application/llsd+xml content type"); | 492 | //m_log.Info("[Debug BASE HTTP SERVER]: found a application/llsd+xml content type"); |
487 | HandleLLSDRequests(request, response); | 493 | HandleLLSDRequests(request, response); |
488 | return; | 494 | return; |
489 | 495 | ||
490 | case "text/xml": | 496 | case "text/xml": |
491 | case "application/xml": | 497 | case "application/xml": |
498 | case "application/json": | ||
492 | default: | 499 | default: |
493 | //m_log.Info("[Debug BASE HTTP SERVER]: in default handler"); | 500 | //m_log.Info("[Debug BASE HTTP SERVER]: in default handler"); |
494 | // Point of note.. the DoWeHaveA methods check for an EXACT path | 501 | // Point of note.. the DoWeHaveA methods check for an EXACT path |
@@ -529,9 +536,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
529 | // with the minimum first | 536 | // with the minimum first |
530 | m_log.WarnFormat("[BASE HTTP SERVER]: HandleRequest threw {0}.\nNOTE: this may be spurious on Linux", e); | 537 | m_log.WarnFormat("[BASE HTTP SERVER]: HandleRequest threw {0}.\nNOTE: this may be spurious on Linux", e); |
531 | } | 538 | } |
532 | catch (EndOfStreamException e) | 539 | catch (IOException e) |
533 | { | 540 | { |
534 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); | 541 | m_log.ErrorFormat("[BASE HTTP SERVER] HandleRequest() threw ", e); |
535 | } | 542 | } |
536 | catch (InvalidOperationException e) | 543 | catch (InvalidOperationException e) |
537 | { | 544 | { |
@@ -760,6 +767,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
760 | // This has to be here to prevent a Linux/Mono crash | 767 | // This has to be here to prevent a Linux/Mono crash |
761 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); | 768 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); |
762 | } | 769 | } |
770 | catch (IOException e) | ||
771 | { | ||
772 | m_log.Warn("[BASE HTTP SERVER] XmlRpcRequest issue: " + e.Message); | ||
773 | } | ||
763 | } | 774 | } |
764 | return; | 775 | return; |
765 | //responseString = "Error"; | 776 | //responseString = "Error"; |
@@ -793,6 +804,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
793 | // This has to be here to prevent a Linux/Mono crash | 804 | // This has to be here to prevent a Linux/Mono crash |
794 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); | 805 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); |
795 | } | 806 | } |
807 | catch (IOException e) | ||
808 | { | ||
809 | m_log.Warn("[BASE HTTP SERVER] XmlRpcRequest issue: " + e.Message); | ||
810 | } | ||
796 | } | 811 | } |
797 | } | 812 | } |
798 | 813 | ||
@@ -823,7 +838,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
823 | } | 838 | } |
824 | try | 839 | try |
825 | { | 840 | { |
826 | llsdRequest = OSDParser.DeserializeLLSDXml(requestBody); | 841 | llsdRequest = OSDParser.Deserialize(requestBody); |
827 | } | 842 | } |
828 | catch (Exception ex) | 843 | catch (Exception ex) |
829 | { | 844 | { |
@@ -873,10 +888,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
873 | } | 888 | } |
874 | else | 889 | else |
875 | { | 890 | { |
876 | response.ContentType = "application/llsd+xml"; | 891 | // Select an appropriate response format |
877 | //m_log.Info("[Debug BASE HTTP SERVER]: Response: " + llsdResponse.ToString()); | 892 | buffer = BuildLLSDResponse(request, response, llsdResponse); |
878 | buffer = OSDParser.SerializeLLSDXmlBytes(llsdResponse); | ||
879 | } | 893 | } |
894 | |||
880 | response.SendChunked = false; | 895 | response.SendChunked = false; |
881 | response.ContentLength64 = buffer.Length; | 896 | response.ContentLength64 = buffer.Length; |
882 | response.ContentEncoding = Encoding.UTF8; | 897 | response.ContentEncoding = Encoding.UTF8; |
@@ -912,6 +927,47 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
912 | } | 927 | } |
913 | } | 928 | } |
914 | 929 | ||
930 | private byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, OSD llsdResponse) | ||
931 | { | ||
932 | if (request.AcceptTypes != null && request.AcceptTypes.Length > 0) | ||
933 | { | ||
934 | foreach (string strAccept in request.AcceptTypes) | ||
935 | { | ||
936 | switch (strAccept) | ||
937 | { | ||
938 | case "application/llsd+xml": | ||
939 | case "application/xml": | ||
940 | case "text/xml": | ||
941 | response.ContentType = strAccept; | ||
942 | return OSDParser.SerializeLLSDXmlBytes(llsdResponse); | ||
943 | case "application/llsd+json": | ||
944 | case "application/json": | ||
945 | response.ContentType = strAccept; | ||
946 | return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(llsdResponse)); | ||
947 | } | ||
948 | } | ||
949 | } | ||
950 | |||
951 | if (!String.IsNullOrEmpty(request.ContentType)) | ||
952 | { | ||
953 | switch (request.ContentType) | ||
954 | { | ||
955 | case "application/llsd+xml": | ||
956 | case "application/xml": | ||
957 | case "text/xml": | ||
958 | response.ContentType = request.ContentType; | ||
959 | return OSDParser.SerializeLLSDXmlBytes(llsdResponse); | ||
960 | case "application/llsd+json": | ||
961 | case "application/json": | ||
962 | response.ContentType = request.ContentType; | ||
963 | return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(llsdResponse)); | ||
964 | } | ||
965 | } | ||
966 | |||
967 | response.ContentType = "application/llsd+json"; | ||
968 | return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(llsdResponse)); | ||
969 | } | ||
970 | |||
915 | /// <summary> | 971 | /// <summary> |
916 | /// Checks if we have an Exact path in the LLSD handlers for the path provided | 972 | /// Checks if we have an Exact path in the LLSD handlers for the path provided |
917 | /// </summary> | 973 | /// </summary> |
@@ -1404,6 +1460,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1404 | // This has to be here to prevent a Linux/Mono crash | 1460 | // This has to be here to prevent a Linux/Mono crash |
1405 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); | 1461 | m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); |
1406 | } | 1462 | } |
1463 | catch (IOException e) | ||
1464 | { | ||
1465 | m_log.Warn("[BASE HTTP SERVER] XmlRpcRequest issue: " + e.Message); | ||
1466 | } | ||
1407 | } | 1467 | } |
1408 | } | 1468 | } |
1409 | 1469 | ||