Skip to content

Commit

Permalink
- Handle the Accept-Encoding header to hopefully fix IE6-behind-proxy…
Browse files Browse the repository at this point in the history
… issues.

- Removed dead code
  • Loading branch information
Katharine committed Apr 19, 2008
1 parent c38ebab commit 76ad797
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 63 deletions.
2 changes: 1 addition & 1 deletion server/Crypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public RSAParameters ExportParameters(bool includePrivateParameters)
return _sp.ExportParameters(includePrivateParameters);
}

// Use 1,024 bit encryption.
// Use 1,024 bit encryption by default.
public void InitCrypto()
{
InitCrypto(1024);
Expand Down
5 changes: 2 additions & 3 deletions server/Html/Connect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ private void RegisterCallbacks(User user)
client.Assets.OnAssetUploaded += new AssetManager.AssetUploadedCallback(events.Assets_OnAssetUploaded);

// Packet callbacks
// We register these because there's no LibSL function dor doing it easily.
// We register these because there's no LibSL function for doing it easily.
client.Network.RegisterCallback(PacketType.AvatarPropertiesReply, new NetworkManager.PacketCallback(events.Avatars_OnAvatarProperties));
// Manual map handler. I hear rumours that the next libsl will have its own
// map support.
// Manual map handler.
client.Network.RegisterCallback(PacketType.MapBlockReply, new NetworkManager.PacketCallback(events.Packet_MapBlockReply));
client.Network.RegisterCallback(PacketType.MapItemReply, new NetworkManager.PacketCallback(events.Packet_MapItemReply));
}
Expand Down
25 changes: 25 additions & 0 deletions server/Html/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@ public void OnFileRequested(HttpRequest request, IDirectory directory)
}
hash.Add("GRID_OPTIONS", grids);
hash.Add("SEARCH_ROOT", AjaxLife.StringToJSON(AjaxLife.SEARCH_ROOT));
if (AjaxLife.HANDLE_CONTENT_ENCODING)
{
// S3 doesn't support Accept-Encoding, so we do it ourselves.
if (request.Headers["Accept-Encoding"] != null)
{
string[] accept = request.Headers["Accept-Encoding"].Split(',');
foreach (string encoding in accept)
{
string parsedencoding = encoding.Split(';')[0];
if (parsedencoding == "gzip" || parsedencoding == "*") // Should we really honour "*"? Specs aside, it's never going to be true.
{
hash.Add("SPECIAL", "gzip");
break;
}
}
}
else
{
hash.Add("SPECIAL", "plain");
}
}
else
{
hash.Add("SPECIAL", "plain");
}
// Parse the template.
Html.Template.Parser parser = new Html.Template.Parser(hash);
writer.Write(parser.Parse(File.ReadAllText("Html/Templates/AjaxLife.html")));
Expand Down
16 changes: 1 addition & 15 deletions server/Html/Templates/AjaxLife.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,13 @@
<title>AjaxLife</title>
<link href="{STATIC_ROOT}resources/css/ext-all.css" type="text/css" rel="stylesheet" />
<link href="{STATIC_ROOT}resources/css/ytheme-aero.css" type="text/css" rel="stylesheet" />
<!-- The below is not used on IE before IE7. -->
<!--[if gte IE 7]-->
<script type="text/javascript" src="{STATIC_ROOT}AjaxLife.Libs.js"></script>
<script type="text/javascript" src="{STATIC_ROOT}Crypto.js"></script>
<link href="{STATIC_ROOT}login.css" type="text/css" rel="stylesheet" />
<link href="{STATIC_ROOT}ui.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="{STATIC_ROOT}login.js"></script>
<!-- The really big file -->
<!-- <script type="text/javascript" src="{STATIC_ROOT}AjaxLife.All.js"></script> -->
<!--[endif]-->

<!-- The below is only used on IE before IE7. -->
<!--[if lt IE 7]>
<script type="text/javascript" src="{STATIC_ROOT}AjaxLife.Libs.IE6.js"></script>
<script type="text/javascript" src="{STATIC_ROOT}Crypto.IE6.js"></script>
<link href="{STATIC_ROOT}login.IE6.css" type="text/css" rel="stylesheet" />
<link href="{STATIC_ROOT}ui.IE6.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="{STATIC_ROOT}login.IE6.js"></script>
<script type="text/javascript" src="{STATIC_ROOT}AjaxLife.All.IE6.js"></script>
<![endif]-->
<!-- If you do development in IE6 (or lower), you will have to comment out the above line.
<!-- <script type="text/javascript" src="{STATIC_ROOT}AjaxLife.All.{SPECIAL}.js"></script> -->

<!-- The below is used for development. -->
<script src="{STATIC_ROOT}AjaxLife.js" type="text/javascript"></script>
Expand Down
48 changes: 4 additions & 44 deletions server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class AjaxLife
public static string STATIC_ROOT { get { return StaticRoot; } }
public static string SEARCH_ROOT { get { return SearchRoot; } }
public static bool USE_S3 { get { return UseS3; } }
public static bool HANDLE_CONTENT_ENCODING { get { return HandleContentEncoding; } }

// Constant - the number of seconds before the session times out and logs you off.
// This handles people losing their internet connection or closing the window without
Expand All @@ -66,6 +67,7 @@ class AjaxLife
private static string PrivateAccessKey = "";
private static string TextureCache = "texturecache/";
private static string SearchRoot = "http://services.katharineberry.co.uk/search/"; // Unused, currently.
private static bool HandleContentEncoding = false;
private static bool UseS3 = false;

public static int TextureCacheCount = 0; // Temporarily completely unused.
Expand Down Expand Up @@ -157,6 +159,7 @@ public AjaxLife(string[] arg)
{
TextureRoot = args["textureroot"];
}
HandleContentEncoding = (args["doencoding"] != null);
// Create an empty dictionary for the users. This is defined as public further up.
Users = new Dictionary<Guid, User>();

Expand Down Expand Up @@ -250,50 +253,7 @@ public AjaxLife(string[] arg)
// Sleep forever. Note that this means nothing after this line ever gets executed.
// We do this because no more processing takes place in this thread.
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
//TODO: Move this into another function and come up with a secure way of calling it.
timer.Stop();
Console.WriteLine("Initiating shutdown sequence.");
timer.Dispose();
Console.WriteLine("Notifying clients...");
// Loop through each user.
foreach (KeyValuePair<Guid,User> entry in Users)
{
try
{
User user = entry.Value;
if (user.Events != null)
{
// Manually send the OnDisconnected event.
user.Events.Network_OnDisconnected(NetworkManager.DisconnectType.ServerInitiated, "The AjaxLife server is shutting down.\n");
}
}
catch(Exception e)
{
Console.WriteLine("Failed to transmit a logout notice: "+e.Message);
}
}
Console.WriteLine("Waiting a bit...");
System.Threading.Thread.Sleep(10000); // Sleep for ten seconds while clients work out they're out.
Console.WriteLine("Disconnecting agents...");
// Loop through again and log them out.
foreach (KeyValuePair<Guid,User> user in Users)
{
try
{
SecondLife sl = user.Value.Client;
if (sl.Network.Connected)
{
sl.Network.Logout();
}
}
catch
{
Console.WriteLine("Failed to log out an agent.");
}
}
// Gracefully stop the webserver.
webserver.Stop();
// RTS ;)
// We never get past this point, so all code past here has been deleted for now.
}

// Loop through each user and mark them for deletion if they haven't made a request
Expand Down

0 comments on commit 76ad797

Please sign in to comment.