Skip to content

Instantly share code, notes, and snippets.

@justincc
Created December 12, 2014 00:58
Show Gist options
  • Save justincc/74305bb0b1a84f25c5e5 to your computer and use it in GitHub Desktop.
Save justincc/74305bb0b1a84f25c5e5 to your computer and use it in GitHub Desktop.
Temporary patch to get CORS working on OpenSimulator for viewfinite
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 093855c..11d8380 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -714,6 +714,8 @@ namespace OpenSim.Framework.Servers.HttpServer
response.OutputStream.Write(buffer, 0, buffer.Length);
}
+ response.AddHeader("Access-Control-Allow-Origin", "*");
+
// Do not include the time taken to actually send the response to the caller in the measurement
// time. This is to avoid logging when it's the client that is slow to process rather than the
// server
@@ -1547,8 +1549,16 @@ namespace OpenSim.Framework.Servers.HttpServer
switch (request.HttpMethod)
{
case "OPTIONS":
- response.StatusCode = (int)OSHttpStatusCode.SuccessOk;
- return null;
+ response.ContentType = "text/plain";
+ response.AddHeader("Access-Control-Allow-Origin", "*");
+ response.AddHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT");
+ response.AddHeader("Access-Control-Max-Age", "1000");
+ //response.AddHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type, origin, authorization, accept, client-security-token");
+ response.AddHeader("Access-Control-Allow-Headers", "content-type");
+// response.KeepAlive = true;
+// response.StatusCode = (int)OSHttpStatusCode.SuccessOk;
+ Console.WriteLine("HERE");
+ return null;
default:
return HandleContentVerbs(request, response);
@@ -1759,6 +1769,8 @@ namespace OpenSim.Framework.Servers.HttpServer
if (responsedata.ContainsKey("access_control_allow_origin"))
response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]);
+ response.AddHeader("Access-Control-Allow-Origin", "*");
+
//Even though only one other part of the entire code uses HTTPHandlers, we shouldn't expect this
//and should check for NullReferenceExceptions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment