urllib (and urllib2) read all data from page on open()?

A

Alex Stapleton

The entire page is downloaded immediately whether you want it to or not when
you do an http request using urllib. This seems slightly broken to me.

Is there anyway to turn this behaviour off and have the objects read method
actually read data from the socket when you ask it to?
 
F

Fuzzyman

Alex said:
Except wouldn't it of already read the entire file when it opened, or does
it occour on the first read()?

Don't know, sorry. Try looking at the source code - it should be
reasonably obvious.
Also will the data returned from
handle.read(100) be raw HTTP? In which case what if the encoding is chunked
or gzipped?

No - you get html - with the http stuff already handled (at least to
the best of my knowledge).

Regards,


Fuzzy
http://www.voidspace.org.uk/python/index.shtml
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top