Re: HTTPConncetion - HEAD request

2011-06-19 Thread Elias Fotinis
On Fri, 17 Jun 2011 20:53:39 +0300, gervaz wrote: I decided to implement this solution: class HeadRequest(urllib.request.Request): def get_method(self): return "HEAD" Now I download the url using: r = HeadRequest(url, None, self.headers) c = urllib.request.urlopen(r) but I don't

Re: HTTPConncetion - HEAD request

2011-06-17 Thread gervaz
On 17 Giu, 12:14, Adam Tauno Williams wrote: > On Thu, 2011-06-16 at 15:43 -0700, gervaz wrote: > > Hi all, can someone tell me why the read() function in the following > > py3 code returns b'' > > >>> h = http.client.HTTPConnection("www.twitter.com") > > >>> h.connect() > > >>> h.request("HEAD",

Re: HTTPConncetion - HEAD request

2011-06-17 Thread Adam Tauno Williams
On Thu, 2011-06-16 at 15:43 -0700, gervaz wrote: > Hi all, can someone tell me why the read() function in the following > py3 code returns b'' > >>> h = http.client.HTTPConnection("www.twitter.com") > >>> h.connect() > >>> h.request("HEAD", "/", "HTTP 1.0") > >>> r = h.getresponse() > >>> r.read()

Re: HTTPConncetion - HEAD request

2011-06-17 Thread Chris Angelico
On Fri, Jun 17, 2011 at 6:19 PM, gervaz wrote: > The fact is that I have a list of urls and I wanted to retrieve the > minimum necessary information in order to understand if the link is a > valid html page or e.g. a picture or something else. As far as I > understood here http://www.w3.org/Protoc

Re: HTTPConncetion - HEAD request

2011-06-17 Thread gervaz
On 17 Giu, 01:00, Ian Kelly wrote: > On Thu, Jun 16, 2011 at 4:43 PM, gervaz wrote: > > Hi all, can someone tell me why the read() function in the following > > py3 code returns b''? > > h = http.client.HTTPConnection("www.twitter.com") > h.connect() > h.request("HEAD", "/", "HTTP

Re: HTTPConncetion - HEAD request

2011-06-16 Thread Ian Kelly
On Thu, Jun 16, 2011 at 4:43 PM, gervaz wrote: > Hi all, can someone tell me why the read() function in the following > py3 code returns b''? > h = http.client.HTTPConnection("www.twitter.com") h.connect() h.request("HEAD", "/", "HTTP 1.0") r = h.getresponse() r.read() > b

HTTPConncetion - HEAD request

2011-06-16 Thread gervaz
Hi all, can someone tell me why the read() function in the following py3 code returns b''? >>> h = http.client.HTTPConnection("www.twitter.com") >>> h.connect() >>> h.request("HEAD", "/", "HTTP 1.0") >>> r = h.getresponse() >>> r.read() b'' Thanks, Mattia -- http://mail.python.org/mailman/listi