tag:blogger.com,1999:blog-5430866.post154955024920185402..comments2024-01-02T08:54:14.406-05:00Comments on Peter Bromberg's UnBlog: Get File Length over http before you download itpeterbromberghttp://www.blogger.com/profile/18173639411723574123noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5430866.post-22104092226569632202010-11-19T06:08:11.202-05:002010-11-19T06:08:11.202-05:00As soon as the server responds to your GET request...As soon as the server responds to your GET request, it sends the HTTP headers along with the beginning of the file (whatever can fit in the few few packets). Once .NET processes the first few packets of data, the code above forcibly terminates the connection with the server.it outsourcing serviceshttp://www.tenaxtechnologies.comnoreply@blogger.comtag:blogger.com,1999:blog-5430866.post-45655673217651676032010-08-31T17:09:21.351-05:002010-08-31T17:09:21.351-05:00@Zubair.NET!
As Huseyin and John both pointed out...@Zubair.NET! <br />As Huseyin and John both pointed out, making a HEAD request is the best solution.peterbromberghttps://www.blogger.com/profile/18173639411723574123noreply@blogger.comtag:blogger.com,1999:blog-5430866.post-38893182505975599112010-08-29T23:58:06.131-05:002010-08-29T23:58:06.131-05:00This means loading the entire file in memory to ge...This means loading the entire file in memory to get the size? looks so inefficient to me.Zubair.NET!https://www.blogger.com/profile/04440853916458308353noreply@blogger.comtag:blogger.com,1999:blog-5430866.post-51361973935392260952010-08-29T20:37:56.975-05:002010-08-29T20:37:56.975-05:00Peter, unfortunately what you (and the forum poste...Peter, unfortunately what you (and the forum poster) are stating is only partially true. Although the entire file is not downloaded, part of the file is downloaded.<br /><br />As soon as the server responds to your GET request, it sends the HTTP headers along with the beginning of the file (whatever can fit in the few few packets). Once .NET processes the first few packets of data, the code above forcibly terminates the connection with the server.<br /><br />However, if you look at the wireshark capture below, you can see some of the zip file was sent across the wire. The commenter who posted about using HEAD is stating the correct mechanism for doing what the poster asked.<br /><br />Hope that helps,<br />John<br /><br />GET /FileUpload/1145921998_ObjectDumper.zip HTTP/1.1<br />Host: www.eggheadcafe.com<br />Connection: Keep-Alive<br /><br />HTTP/1.1 200 OK<br />Content-Type: application/x-zip-compressed<br />Last-Modified: Sat, 28 Aug 2010 20:00:56 GMT<br />Accept-Ranges: bytes<br />ETag: "ad35ebaeb46cb1:0"<br />Server: Microsoft-IIS/7.0<br />X-Powered-By: ASP.NET<br />Date: Mon, 30 Aug 2010 01:23:29 GMT<br />Content-Length: 85827<br /><br />PK...........=,.O.....p.......ObjectDumper.sln...n.@.......^..%.....v.m..0.....j.A.....>Y.}..BwS...*..3.g......O]...Tdb...<+....E....I.s13(OX..".FR..L%m..P.....h.l/./l.....C........v...". .<br /><br />(I truncated the wireshark capture here)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5430866.post-27250902918835182292010-08-28T17:47:52.924-05:002010-08-28T17:47:52.924-05:00Alternatively, you can make a HEAD request to that...Alternatively, you can make a HEAD request to that web resource, see:<br /><br />http://forrst.com/posts/HEAD_requst_to_get_ContentLength-yVhHuseyin Tufekcilerlihttps://www.blogger.com/profile/02347426647143991400noreply@blogger.comtag:blogger.com,1999:blog-5430866.post-71969829440235624942010-08-28T17:24:22.363-05:002010-08-28T17:24:22.363-05:00That's a neat trick!That's a neat trick!Jef Claeshttp://jclaes.blogspot.comnoreply@blogger.com