473,322 Members | 1,846 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,322 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
Nov 20 '05 #1
7 1211
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?

Nov 20 '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?


Nov 20 '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
Nov 20 '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

Nov 20 '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


Nov 20 '05 #6
* "Bryan Martin" <uc*@ftc.gov> scripsit:
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.


<http://www.codeproject.com/csharp/WebDownload.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7
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.
Nov 20 '05 #8

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

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
6
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: 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,...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.