hi friends,
I building a simple downloader application in python using urllib2.
now i have a major problem with urllib2.
i used this type of the code:
i think my code was correct, But urllib2 giving empty output ("") in the middle of the file.PHP Code:
import urllib2
connection = urllib2.urlopen("http://softwareroxer.110mb.com/apps/rdm/rdm0.9-1alpha.deb.zip")
rec_size = 0
fsize = connection.headers(["Content-Length"])
while 1:
Out = connection.read(5*1024) #5kb buffer
rec_size = len(Out)+rec_size
if rec_size == fsize:
print "File size matched"
break
elif Out == "":
print "Empty output...."
print rec_size,fsize
else:pass
I have also tried with httplib, but the same error occurred.
Note:
i am using threads for this connections.
whats wrong with urllib or my code, I can't get any ideas about this ,
please help me friends.
thanks in advance.
Bookmarks