Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7815

Re: HTTPConncetion - HEAD request

Subject Re: HTTPConncetion - HEAD request
From Adam Tauno Williams <awilliam@whitemice.org>
References <b06bf827-671c-4555-b3ec-108bc5c3a0b8@m10g2000yqd.googlegroups.com>
Organization Whitemice Consulting
Date 2011-06-17 06:14 -0400
Newsgroups comp.lang.python
Message-ID <mailman.69.1308304747.1164.python-list@python.org> (permalink)

Show all headers | View raw


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()
> b''

Because there is no body in a HEAD request.  What is useful are the
Content-Type, Content-Length, and etag headers.

Is r.getcode() == 200?  That indicates a successful response; you
*always* much check the response code before interpreting the response.

Also I'm pretty sure that "HTTP 1.0" is wrong.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

HTTPConncetion - HEAD request gervaz <gervaz@gmail.com> - 2011-06-16 15:43 -0700
  Re: HTTPConncetion - HEAD request Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-16 17:00 -0600
    Re: HTTPConncetion - HEAD request gervaz <gervaz@gmail.com> - 2011-06-17 01:19 -0700
      Re: HTTPConncetion - HEAD request Chris Angelico <rosuav@gmail.com> - 2011-06-17 18:44 +1000
  Re: HTTPConncetion - HEAD request Adam Tauno Williams <awilliam@whitemice.org> - 2011-06-17 06:14 -0400
    Re: HTTPConncetion - HEAD request gervaz <gervaz@gmail.com> - 2011-06-17 10:53 -0700
      Re: HTTPConncetion - HEAD request "Elias Fotinis" <efotinis@yahoo.com> - 2011-06-19 16:21 +0300

csiph-web