diff --git a/OpenRA.FileFormats/HttpUtil.cs b/OpenRA.FileFormats/HttpUtil.cs deleted file mode 100644 index d819922868..0000000000 --- a/OpenRA.FileFormats/HttpUtil.cs +++ /dev/null @@ -1,97 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Text; - -namespace OpenRA.FileFormats -{ - public static class HttpUtil - { - public static byte[] DownloadData(string url, Action f, int chunkSize) - { - var uri = new Uri(url); - var ip = Dns.GetHostEntry(uri.DnsSafeHost).AddressList[0]; - - using (var s = new TcpClient()) - { - s.Connect(new IPEndPoint(ip, uri.Port)); - var ns = s.GetStream(); - var sw = new StreamWriter(ns); - - sw.Write("GET {0} HTTP/1.0\r\nHost:{1}\r\n\r\n", uri.PathAndQuery, uri.Host); - sw.Flush(); - - var br = new BinaryReader(ns); - var contentLength = 0; - var offset = 0; - for (; ; ) - { - var result = br.ReadLine(); - var kv = result.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries); - - if (result == "") - { - /* data follows the blank line */ - - if (contentLength > 0) - { - if (f != null) - f(offset, contentLength); - - var data = new byte[contentLength]; - while (offset < contentLength) - { - var thisChunk = Math.Min(contentLength - offset, chunkSize); - br.Read(data, offset, thisChunk); - offset += thisChunk; - if (f != null) - f(offset, contentLength); - } - s.Close(); - return data; - } - else - { - s.Close(); - return new byte[] { }; - } - } - else if (kv[0] == "Content-Length") - contentLength = int.Parse(kv[1]); - } - } - } - - public static byte[] DownloadData(string url, Action f) - { - return DownloadData(url, f, 4096); - } - - public static byte[] DownloadData(string url) - { - return DownloadData(url, null); - } - - static string ReadLine(this BinaryReader br) - { - var sb = new StringBuilder(); - char c; - while ((c = br.ReadChar()) != '\n') - if (c != '\r' && c != '\n') - sb.Append(c); - - return sb.ToString(); - } - } -} diff --git a/OpenRA.FileFormats/OpenRA.FileFormats.csproj b/OpenRA.FileFormats/OpenRA.FileFormats.csproj index f2671a4169..f97116332b 100644 --- a/OpenRA.FileFormats/OpenRA.FileFormats.csproj +++ b/OpenRA.FileFormats/OpenRA.FileFormats.csproj @@ -85,7 +85,6 @@ -