small tweak to HttpUtil - we don't support 1.1, so dont pretend we do; also, set WebClient.Proxy everywhere to null

This commit is contained in:
Chris Forbes
2011-01-04 20:02:23 +13:00
parent fe720186f5
commit dcbb6ee4eb
4 changed files with 19 additions and 17 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRA.FileFormats
var ns = s.GetStream(); var ns = s.GetStream();
var sw = new StreamWriter(ns); var sw = new StreamWriter(ns);
sw.Write("GET {0} HTTP/1.1\r\nHost:{1}\r\n\r\n", uri.PathAndQuery, uri.Host); sw.Write("GET {0} HTTP/1.0\r\nHost:{1}\r\n\r\n", uri.PathAndQuery, uri.Host);
sw.Flush(); sw.Flush();
var br = new BinaryReader(ns); var br = new BinaryReader(ns);

View File

@@ -62,6 +62,7 @@ namespace OpenRA.Server
static string GetData(Uri uri) static string GetData(Uri uri)
{ {
var wc = new WebClient(); var wc = new WebClient();
wc.Proxy = null;
var data = wc.DownloadData(uri); var data = wc.DownloadData(uri);
return Encoding.UTF8.GetString(data); return Encoding.UTF8.GetString(data);
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Server
public class MasterServerPinger : ServerTrait, ITick, INotifySyncLobbyInfo, IStartGame public class MasterServerPinger : ServerTrait, ITick, INotifySyncLobbyInfo, IStartGame
{ {
const int MasterPingInterval = 60 * 3; // 3 minutes. server has a 5 minute TTL for games, so give ourselves a bit const int MasterPingInterval = 60 * 3; // 3 minutes. server has a 5 minute TTL for games, so give ourselves a bit
// of leeway. // of leeway.
public int TickTimeout { get { return MasterPingInterval * 10000; } } public int TickTimeout { get { return MasterPingInterval * 10000; } }
public void Tick(S server) public void Tick(S server)
{ {
@@ -29,10 +29,10 @@ namespace OpenRA.Mods.RA.Server
lock (masterServerMessages) lock (masterServerMessages)
while (masterServerMessages.Count > 0) while (masterServerMessages.Count > 0)
server.SendChat(null, masterServerMessages.Dequeue()); server.SendChat(null, masterServerMessages.Dequeue());
} }
public void LobbyInfoSynced(S server) { PingMasterServer(server); } public void LobbyInfoSynced(S server) { PingMasterServer(server); }
public void GameStarted(S server) { PingMasterServer(server); } public void GameStarted(S server) { PingMasterServer(server); }
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Server
static string masterServerUrl = Game.Settings.Server.MasterServer; static string masterServerUrl = Game.Settings.Server.MasterServer;
static int externalPort = Game.Settings.Server.ExternalPort; static int externalPort = Game.Settings.Server.ExternalPort;
static bool isInitialPing = true; static bool isInitialPing = true;
static volatile bool isBusy; static volatile bool isBusy;
static Queue<string> masterServerMessages = new Queue<string>(); static Queue<string> masterServerMessages = new Queue<string>();
public static void PingMasterServer(S server) public static void PingMasterServer(S server)
@@ -61,13 +61,14 @@ namespace OpenRA.Mods.RA.Server
using (var wc = new WebClient()) using (var wc = new WebClient())
{ {
wc.DownloadData( wc.Proxy = null;
masterServerUrl + url.F( wc.DownloadData(
externalPort, Uri.EscapeUriString(server.Name), masterServerUrl + url.F(
server.GameStarted ? 2 : 1, // todo: post-game states, etc. externalPort, Uri.EscapeUriString(server.Name),
server.lobbyInfo.Clients.Count, server.GameStarted ? 2 : 1, // todo: post-game states, etc.
string.Join(",", server.lobbyInfo.GlobalSettings.Mods), server.lobbyInfo.Clients.Count,
server.lobbyInfo.GlobalSettings.Map)); string.Join(",", server.lobbyInfo.GlobalSettings.Mods),
server.lobbyInfo.GlobalSettings.Map));
if (isInitialPing) if (isInitialPing)
{ {
@@ -77,11 +78,11 @@ namespace OpenRA.Mods.RA.Server
} }
} }
} }
catch(Exception ex) catch (Exception ex)
{ {
Log.Write("server", ex.ToString()); Log.Write("server", ex.ToString());
lock( masterServerMessages ) lock (masterServerMessages)
masterServerMessages.Enqueue( "Master server communication failed." ); masterServerMessages.Enqueue("Master server communication failed.");
} }
isBusy = false; isBusy = false;

View File

@@ -118,11 +118,11 @@ namespace OpenRA.Utility
string[] args = argValue.Split(','); string[] args = argValue.Split(',');
string url = args[0]; string url = args[0];
WebClient wc = new WebClient(); WebClient wc = new WebClient();
wc.Proxy = null;
if (args.Length == 1) if (args.Length == 1)
{ {
wc.DownloadStringCompleted += DownloadStringCompleted; wc.DownloadStringCompleted += DownloadStringCompleted;
wc.DownloadStringAsync(new Uri(url)); wc.DownloadStringAsync(new Uri(url));
} }
else if (args.Length == 2) else if (args.Length == 2)