Re: No Content-Length header, nor length property

2015-07-08 Thread zljubisic
> Ah - looking at the response headers, they include "Transfer-Encoding > chunked" - I don't think urlopen handles chunked responses by default, > though I could be wrong, I don't have time to check the docs right now. > > The requests library (https://pypi.python.org/pypi/requests) seems to han

Re: No Content-Length header, nor length property

2015-07-08 Thread Jon Ribbens
On 2015-07-08, zljubi...@gmail.com wrote: > Why I can't get the size of this particular file? > On other servers, the same procedure would return file size in > bytes, but not for this file? > > Does it depend on server itself, or there is a way to get remote > file size before downloading? Yes,

Re: No Content-Length header, nor length property

2015-07-07 Thread Kev Dwyer
zljubi...@gmail.com wrote: > > >> Hello, >> >> urlopen returns an HttpResponse >> object(https://docs.python.org/3/library/http.client.html#httpresponse-objects). >> You need to call read() on the return value to get the page content, or >> you could consider the getheader method to check for

Re: No Content-Length header, nor length property

2015-07-07 Thread zljubisic
> Hello, > > urlopen returns an HttpResponse > object(https://docs.python.org/3/library/http.client.html#httpresponse-objects). > You need to call read() on the return value to get the page > content, or you could consider the getheader method to check for a Content- > Length header. > > Hop

Re: No Content-Length header, nor length property

2015-07-07 Thread Kev Dwyer
zljubi...@gmail.com wrote: > Hi, > > if I put the link in the browser, I will be offered to save the file to > the local disk. > > If I execute these few lines of code, I will get None: > > import urllib.request > > url = 'http://radio.hrt.hr/prvi-program/aod/download/118467/' > site = urllib.

No Content-Length header, nor length property

2015-07-07 Thread zljubisic
Hi, if I put the link in the browser, I will be offered to save the file to the local disk. If I execute these few lines of code, I will get None: import urllib.request url = 'http://radio.hrt.hr/prvi-program/aod/download/118467/' site = urllib.request.urlopen(url) print('File size:', site.len