473,383 Members | 1,795 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,383 software developers and data experts.

any ideas?

I have some problems with Net.WebClient

This function of mine recieves an array with Urls, and Filenames, and is supposed to download all the files (binary files) that is
listed in the array, but in some cases it dosen't work. Normally it would download files (binary) to a folder, but on some occations
it will only download the first file in the array as a binary, and then the rest of the files downloaded will actually only contain
HTML. These are supposed to be video/images so that's very wrong. If i try downloading the files manually usung Internet Explorer it
works like it should (all files are downloaded as binary).

Private Sub downloadFiles(ByVal files() As FileToUri_Structure, ByVal baseUrl As Uri)
Dim i As Integer
Dim web As New Net.WebClient
Dim h As New Net.WebHeaderCollection
h.Add("Referer", baseUrl.AbsoluteUri)

web.Headers = h

For i = files.GetLowerBound(0) To files.GetUpperBound(0)
web.DownloadFile(files(i).AbsoluteUri, files(i).FilePath)
Debug.WriteLine("i= " & i & vbLf & web.ResponseHeaders.ToString)
Next
End Sub

When i looked at the web.ResponseHeaders i saw that the difference was in the "Server" header. The malfunctioning response also
returned "text/html" as the "Content-Type", and an additional "X-Pad" field. "Connection: close" was also something that was not
returned in the other (working) attempts

i=0
Date: Sat, 16 Oct 2004 21:06:58 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.1
Last-Modified: Mon, 04 Oct 2004 23:34:34 GMT
ETag: "1a5f4a-9d761-4161de0a"
Accept-Ranges: bytes
Content-Length: 644961
Connection: close
Content-Type: text/plain

i=1
Date: Sat, 16 Oct 2004 21:07:01 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.1
Last-Modified: Mon, 12 Apr 2004 06:48:24 GMT
ETag: "39196b-274-407a3bb8"
Accept-Ranges: bytes
Content-Length: 628
Connection: close
Content-Type: text/html
X-Pad: avoid browser bug

I googled and found this: "In six cases the HTTP message "X-Pad: avoid browser bug" was sent. This was an unannounced change to
Apache version 1.2b9 which provided a fix for a bug in Netscape versions 2.x, 3.x and 4.0b2."
(http://www.ariadne.ac.uk/issue34/web-watch)

I tried with another webserver and that returned "Server: Apache/1.3.27 (Unix) PHP/4.3.2" and there downloads worked perfectly.

Based on this result im suspecting that this might be a problem between Apache and PHP version 4.3.1 handling the requests
correctly, but since the first file in the array allways downloads sucessfully, i'm not completely convinced.

I tried adding a delay of 2 seconds between the downloads and but that didn't fix the problem. I also tried to declare a "web = new
Net.WebClient" before each new download in case it was something with the "web" object. I also tried adding additional headers like
"User-Agent" and so on to the "web.Header" that is sendt to the webserver. None of this fixed the problem.

Does anybody know how to go around to solve this.

This is how the "web.ReturnHeaders" of a working download looked like

i=0
Date: Sat, 16 Oct 2004 22:01:30 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.2
Last-Modified: Tue, 21 Sep 2004 23:03:38 GMT
ETag: "71d21f-e151f-4150b34a"
Accept-Ranges: bytes
Content-Length: 922911
Content-Type: text/plain

i=1
Date: Sat, 16 Oct 2004 22:01:35 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.2
Last-Modified: Tue, 21 Sep 2004 23:03:17 GMT
ETag: "71d21e-dd69f-4150b335"
Accept-Ranges: bytes
Content-Length: 906911
Content-Type: text/plain
Nov 21 '05 #1
1 913
Jarod,

Did you already just tried the webclient.downloadfile?

Cor
Nov 21 '05 #2

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

Similar topics

4
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the...
14
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon"...
3
by: Slash | last post by:
Hello everyone I'm looking for seminar topics (and project ideas too) for my final year in Computer Engineering. I'm considering doing something on C++/Linux, considering that I love it so much...
3
by: Charulatha Kalluri | last post by:
Hello folks, I'm on the lookout for project ideas for a C++ class. The project should: -Be a "fairly complex" application
12
by: Anthony Greene | last post by:
Hello, I know this isn't really a python centric question, but I'm seeking help from my fellow python programmers. I've been learning python for the past year and a half, and I still haven't...
10
by: Wildemar Wildenburger | last post by:
Hi there :) I don't know how else to call what I'm currently implementing: An object that behaves like a list but doesn't store it's own items but rather pulls them from a larger list (if they...
0
by: bcannon | last post by:
At Guido's suggestion, a new mailing list has been created named Python-Ideas (http://mail.python.org/mailman/listinfo/python-ideas). This list is meant as a place for speculative, pie-in-the-sky...
224
by: Jon Slaughter | last post by:
Sorry for all the cross posting but I'm interesting in getting a serious discussion about how usenet has become lately. Many people are moving away from usenet because of all the spam and cooks...
0
by: mistersexy | last post by:
I have been programming in python for some time but I have become short of ideas. A software exhibition is coming up, and I plan to show python's worth 'cos it is quite underrated in this part of...
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.