HttpResponse Compression... ?
-
[Intro] To keep the story short, I have created a Download manager creating various simultaneous HttpRequests and downloading the HttpResponses (of the files). In brief, the relevant code looks somewhat like this... dRequest = (HttpWebRequest)WebRequest.Create(txtURL.Text); dRequest.AddRange(dFrom, dTo); dResponse = (HttpWebResponse)dRequest.GetResponse(); Stream dStream = dResponse.GetResponseStream(); ..And of course the download is saved etc etc etc. This all works fine. [End of Intro] Today I was told that I should enable compression (from the server side - whenever possible) when downloading the file in order to speed up the download even more... However, I have no idea how this works or how this can be achieved? I am not asking for someone to do the code for me (although any examples are appreciated), but I would like to know how this can be achieved / how the system works, or what to search for, in order to achieve this? Huge thanks! :-D
-
[Intro] To keep the story short, I have created a Download manager creating various simultaneous HttpRequests and downloading the HttpResponses (of the files). In brief, the relevant code looks somewhat like this... dRequest = (HttpWebRequest)WebRequest.Create(txtURL.Text); dRequest.AddRange(dFrom, dTo); dResponse = (HttpWebResponse)dRequest.GetResponse(); Stream dStream = dResponse.GetResponseStream(); ..And of course the download is saved etc etc etc. This all works fine. [End of Intro] Today I was told that I should enable compression (from the server side - whenever possible) when downloading the file in order to speed up the download even more... However, I have no idea how this works or how this can be achieved? I am not asking for someone to do the code for me (although any examples are appreciated), but I would like to know how this can be achieved / how the system works, or what to search for, in order to achieve this? Huge thanks! :-D
Trapper-Hell wrote:
Today I was told that I should enable compression (from the server side - whenever possible) when downloading the file in order to speed up the download even more... However, I have no idea how this works or how this can be achieved?
Isn't it a setting in IIS? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d52ff289-94d3-4085-bc4e-24eb4f312e0e.mspx?mfr=true[^]
Man who stand on hill with mouth open wait long time for roast duck to drop in
-
[Intro] To keep the story short, I have created a Download manager creating various simultaneous HttpRequests and downloading the HttpResponses (of the files). In brief, the relevant code looks somewhat like this... dRequest = (HttpWebRequest)WebRequest.Create(txtURL.Text); dRequest.AddRange(dFrom, dTo); dResponse = (HttpWebResponse)dRequest.GetResponse(); Stream dStream = dResponse.GetResponseStream(); ..And of course the download is saved etc etc etc. This all works fine. [End of Intro] Today I was told that I should enable compression (from the server side - whenever possible) when downloading the file in order to speed up the download even more... However, I have no idea how this works or how this can be achieved? I am not asking for someone to do the code for me (although any examples are appreciated), but I would like to know how this can be achieved / how the system works, or what to search for, in order to achieve this? Huge thanks! :-D
Please go through the following article which contains exactly what you need Using HTTP Compression for Faster Downloads[^] If you need to increase the speed further then you may use the below code which actually deals in sockets and increases the speed to many folds when parallel downloading is going on. public class MyWebResponse { public MyWebResponse() { } public void Connect(MyWebRequest request) { ResponseUri = request.RequestUri; socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint remoteEP = new IPEndPoint(Dns.Resolve(ResponseUri.Host).AddressList[0], ResponseUri.Port); socket.Connect(remoteEP); } public void SendRequest(MyWebRequest request) { ResponseUri = request.RequestUri; request.Header = request.Method + " " + ResponseUri.PathAndQuery + " HTTP/1.0\r\n" + request.Headers; socket.Send(Encoding.ASCII.GetBytes(request.Header)); } public void SetTimeout(int Timeout) { socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, Timeout * 1000); socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, Timeout * 1000); } public void ReceiveHeader() { Header = ""; Headers = new WebHeaderCollection(); byte[] bytes = new byte[10]; while (socket.Receive(bytes, 0, 1, SocketFlags.None) > 0) { Header += Encoding.ASCII.GetString(bytes, 0, 1); if (bytes[0] == '\n' && Header.EndsWith("\r\n\r\n")) break; } MatchCollection matches = new Regex("[^\r\n]+").Matches(Header.TrimEnd('\r', '\n')); for (int n = 1; n < matches.Count; n++) { string[] strItem = matches[n].Value.Split(new char[] { ':' }, 2); if (strItem.Length > 0) Headers[strItem[0].Trim()] = strItem[1].Trim(); } // check if the page should be transfered to another location if (matches.Count > 0 && ( matches[0].Value.IndexO
-
Please go through the following article which contains exactly what you need Using HTTP Compression for Faster Downloads[^] If you need to increase the speed further then you may use the below code which actually deals in sockets and increases the speed to many folds when parallel downloading is going on. public class MyWebResponse { public MyWebResponse() { } public void Connect(MyWebRequest request) { ResponseUri = request.RequestUri; socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint remoteEP = new IPEndPoint(Dns.Resolve(ResponseUri.Host).AddressList[0], ResponseUri.Port); socket.Connect(remoteEP); } public void SendRequest(MyWebRequest request) { ResponseUri = request.RequestUri; request.Header = request.Method + " " + ResponseUri.PathAndQuery + " HTTP/1.0\r\n" + request.Headers; socket.Send(Encoding.ASCII.GetBytes(request.Header)); } public void SetTimeout(int Timeout) { socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, Timeout * 1000); socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, Timeout * 1000); } public void ReceiveHeader() { Header = ""; Headers = new WebHeaderCollection(); byte[] bytes = new byte[10]; while (socket.Receive(bytes, 0, 1, SocketFlags.None) > 0) { Header += Encoding.ASCII.GetString(bytes, 0, 1); if (bytes[0] == '\n' && Header.EndsWith("\r\n\r\n")) break; } MatchCollection matches = new Regex("[^\r\n]+").Matches(Header.TrimEnd('\r', '\n')); for (int n = 1; n < matches.Count; n++) { string[] strItem = matches[n].Value.Split(new char[] { ':' }, 2); if (strItem.Length > 0) Headers[strItem[0].Trim()] = strItem[1].Trim(); } // check if the page should be transfered to another location if (matches.Count > 0 && ( matches[0].Value.IndexO
Thanks mate! It appears to be just what I wanted... Looks more complex then the methods I'm currently using but I guess that's the way to go... Thanks a lot ;)
-
Thanks mate! It appears to be just what I wanted... Looks more complex then the methods I'm currently using but I guess that's the way to go... Thanks a lot ;)
You welcome buddy :)