473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

HHTP file download:

Ok im trying to figure out how internet explorers file download box always
seem to at least come close to knowing the exact file size/time to download.
From what I can tell its getting its not getting its info from the
content-length. I know this because I can test query against a apache box
that does not return the content length however IE still knows the size of
the files.

What am i missing?

Bryan
Jul 21 '05 #1
6 3733
Cor
Hi Bryan,

I do not believe that you get an answer in a newsgroup what code Internet
Explorer internaly uses.

But what do you want to archieve?

Cor
Ok im trying to figure out how internet explorers file download box always
seem to at least come close to knowing the exact file size/time to download. From what I can tell its getting its not getting its info from the
content-length. I know this because I can test query against a apache box
that does not return the content length however IE still knows the size of
the files.

What am i missing?

Jul 21 '05 #2
You mean I cant download the complete internet explorer source code? I was
not asking for the code only for how they achieved it. I am downloading
files from the internet but due to some files being large I need a way to
display a progress. Again as the original question implies does anyone know
where the dialog is getting a whiff of a file size from?

Bryan

"Cor" <no*@non.com> wrote in message
news:OI******************@TK2MSFTNGP12.phx.gbl...
Hi Bryan,

I do not believe that you get an answer in a newsgroup what code Internet
Explorer internaly uses.

But what do you want to archieve?

Cor
Ok im trying to figure out how internet explorers file download box always seem to at least come close to knowing the exact file size/time to

download.
From what I can tell its getting its not getting its info from the
content-length. I know this because I can test query against a apache box that does not return the content length however IE still knows the size of the files.

What am i missing?


Jul 21 '05 #3
Cor
Hi Bryan,

I am not completly sure of it, but I have distributed this before (I have
this in a program, but I had to delete a lot to make it only for what you
ask)..

\\\not tested as is
dim conlength as string
Dim wbRq As HttpWebRequest = DirectCast(WebRequest.Create(item.Text),
HttpWebRequest)
wbRq.Timeout = 2000
Try
Dim wbRs As HttpWebResponse = DirectCast(wbRq.GetResponse(),
HttpWebResponse)
Dim wbHCol As WebHeaderCollection = wbRs.Headers
For i As Integer = 0 To wbHCol.Count - 1
Dim header As String = wbHCol.GetKey(i)
Dim values As String() = wbHCol.GetValues(header)
If values.Length > 0 andalso header.Tolower = "content-lenght" Then
conlenght = values(0)
End If
Next
wbRs.Close()
Catch
conlength = "?"
End Try
///
I hope this helps a little bit?

Cor
Jul 21 '05 #4
Cor, thanks again for the response however you have missed the question
again. I know you can get the content length from the headers, matter of
fact there is a much easier way to do it than the example you gave. Problem
is not all servers send a content length so I would like to know how for
instance internet explorer's download dialog knows the file size so it can
give you a idea of how long its gonna take you to download the file. Again
as stated I have downloaded files from a server I know is not giving a
content length and internet explorer's dialog box still correctly displays
the time/progress while downloading.

BTW the httpwebresponse has a "contentlength" method which will return the
value without having to loop through all headers.

Bryan

Dim str_Site As String = "http://download.winzip.com/winzip81.exe"
Dim obj_HTTPWebRequest As System.Net.HttpWebRequest =
System.Net.HttpWebRequest.Create(str_Site)
Dim obj_HTTPWebResponse As System.Net.HttpWebResponse =
obj_HTTPWebRequest.GetResponse
Debug.WriteLine(obj_HTTPWebResponse.ContentLength)
"Cor" <no*@non.com> wrote in message
news:OU****************@TK2MSFTNGP12.phx.gbl...
Hi Bryan,

I am not completly sure of it, but I have distributed this before (I have
this in a program, but I had to delete a lot to make it only for what you
ask)..

\\\not tested as is
dim conlength as string
Dim wbRq As HttpWebRequest = DirectCast(WebRequest.Create(item.Text),
HttpWebRequest)
wbRq.Timeout = 2000
Try
Dim wbRs As HttpWebResponse = DirectCast(wbRq.GetResponse(),
HttpWebResponse)
Dim wbHCol As WebHeaderCollection = wbRs.Headers
For i As Integer = 0 To wbHCol.Count - 1
Dim header As String = wbHCol.GetKey(i)
Dim values As String() = wbHCol.GetValues(header)
If values.Length > 0 andalso header.Tolower = "content-lenght" Then conlenght = values(0)
End If
Next
wbRs.Close()
Catch
conlength = "?"
End Try
///
I hope this helps a little bit?

Cor

Jul 21 '05 #5
Well, I've never done this with VB.NET, but in using C++ and windows sockets
I simply sent a HEAD request to the server to get the content length before
requesting the file with the GET method.

Here is some information from the HTTP RFC concerning content length and
what to do if a content length header is not returned....

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

14.13 Content-Length
The Content-Length entity-header field indicates the size of the
entity-body, in decimal number of OCTETs, sent to the recipient or, in the
case of the HEAD method, the size of the entity-body that would have been
sent had the request been a GET.

Content-Length = "Content-Length" ":" 1*DIGIT
An example is

Content-Length: 3495
Applications SHOULD use this field to indicate the transfer-length of the
message-body, unless this is prohibited by the rules in section 4.4.

Any Content-Length greater than or equal to zero is a valid value. Section
4.4 describes how to determine the length of a message-body if a
Content-Length is not given.

Note that the meaning of this field is significantly different from the
corresponding definition in MIME, where it is an optional field used within
the "message/external-body" content-type. In HTTP, it SHOULD be sent
whenever the message's length can be determined prior to being transferred,
unless this is prohibited by the rules in section 4.4.

Here's a link to section 4.4 that's mentioned....

http://www.w3.org/Protocols/rfc2616/...c4.html#sec4.4

"Bryan Martin" <uc*@ftc.gov> wrote in message
news:em****************@TK2MSFTNGP09.phx.gbl...
Cor, thanks again for the response however you have missed the question
again. I know you can get the content length from the headers, matter of
fact there is a much easier way to do it than the example you gave. Problem is not all servers send a content length so I would like to know how for
instance internet explorer's download dialog knows the file size so it can
give you a idea of how long its gonna take you to download the file. Again as stated I have downloaded files from a server I know is not giving a
content length and internet explorer's dialog box still correctly displays
the time/progress while downloading.

BTW the httpwebresponse has a "contentlength" method which will return the
value without having to loop through all headers.

Bryan

Dim str_Site As String = "http://download.winzip.com/winzip81.exe"
Dim obj_HTTPWebRequest As System.Net.HttpWebRequest =
System.Net.HttpWebRequest.Create(str_Site)
Dim obj_HTTPWebResponse As System.Net.HttpWebResponse =
obj_HTTPWebRequest.GetResponse
Debug.WriteLine(obj_HTTPWebResponse.ContentLength)
"Cor" <no*@non.com> wrote in message
news:OU****************@TK2MSFTNGP12.phx.gbl...
Hi Bryan,

I am not completly sure of it, but I have distributed this before (I have this in a program, but I had to delete a lot to make it only for what you ask)..

\\\not tested as is
dim conlength as string
Dim wbRq As HttpWebRequest = DirectCast(WebRequest.Create(item.Text),
HttpWebRequest)
wbRq.Timeout = 2000
Try
Dim wbRs As HttpWebResponse = DirectCast(wbRq.GetResponse(),
HttpWebResponse)
Dim wbHCol As WebHeaderCollection = wbRs.Headers
For i As Integer = 0 To wbHCol.Count - 1
Dim header As String = wbHCol.GetKey(i)
Dim values As String() = wbHCol.GetValues(header)
If values.Length > 0 andalso header.Tolower = "content-lenght"

Then
conlenght = values(0)
End If
Next
wbRs.Close()
Catch
conlength = "?"
End Try
///
I hope this helps a little bit?

Cor


Jul 21 '05 #6
Bryan Martin wrote:
You mean I cant download the complete internet explorer source code? I was

Actually, you can.
http://www.miami.com/mld/miamiherald...al/8007258.htm

Also, search on Kazaa yields a healthy resultset.

If you are really curious that is.
Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: VR | last post by:
Hi, all. I have a rookie web development question. I am working on creating a web site, where all pages are going to have a similar look/feel: same menu on one side, company logo on the other...
0
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
0
by: Rhys666 | last post by:
Basically I have a link that opens my download page and the querystring identifies the type of 'template' Excel spreadsheet has asked to download. The download page reads the querystring,...
7
by: Bryan Martin | last post by:
Ok im trying to figure out how internet explorers file download box always seem to at least come close to knowing the exact file size/time to download. From what I can tell its getting its not...
3
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. ...
16
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
4
by: Roberto Mora | last post by:
I have not done programming in a very long time and what is worst, I never learned VB. Although my job does not require this knowledge, I cam across a problem that although it seemed simple it has...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.