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


Groups > comp.lang.python > #7815

Re: HTTPConncetion - HEAD request

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <awilliam@whitemice.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'indicates': 0.09; 'interpreting': 0.09; '>>>': 0.12; 'wrote:': 0.14; '*always*': 0.16; "b''": 0.16; 'from:addr:awilliam': 0.16; 'from:addr:whitemice.org': 0.16; 'from:name:adam tauno williams': 0.16; 'py3': 0.16; 'read()': 0.16; 'received:72.14.190': 0.16; 'received:72.14.190.87': 0.16; 'received:mail.wmmi.net': 0.16; 'received:wmmi.net': 0.16; 'reply-to:addr:awilliam': 0.16; 'reply- to:addr:whitemice.org': 0.16; 'x-mailer:evolution 2.30.1.2': 0.16; 'header:In-Reply-To:1': 0.21; 'thu,': 0.22; 'code': 0.24; 'function': 0.25; 'received:72.14': 0.26; "i'm": 0.27; 'all,': 0.30; 'someone': 0.33; 'to:addr:python-list': 0.33; 'there': 0.35; '-0700,': 0.35; 'skip:h 40': 0.35; 'useful': 0.37; 'response': 0.37; 'pretty': 0.37; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'body': 0.61; 'response.': 0.68; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72
Subject Re: HTTPConncetion - HEAD request
From Adam Tauno Williams <awilliam@whitemice.org>
To python-list@python.org
In-Reply-To <b06bf827-671c-4555-b3ec-108bc5c3a0b8@m10g2000yqd.googlegroups.com>
References <b06bf827-671c-4555-b3ec-108bc5c3a0b8@m10g2000yqd.googlegroups.com>
Content-Type text/plain; charset="UTF-8"
Organization Whitemice Consulting
Date Fri, 17 Jun 2011 06:14:38 -0400
Mime-Version 1.0
X-Mailer Evolution 2.30.1.2
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To awilliam@whitemice.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.69.1308304747.1164.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 82.94.164.166
X-Trace 1308304747 news.xs4all.nl 49183 [::ffff:82.94.164.166]:57750
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7815

Show key headers only | 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