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


Groups > comp.lang.python > #7774

Re: HTTPConncetion - HEAD request

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '>>>>': 0.09; 'pm,': 0.10; 'wrote:': 0.14; "b''": 0.16; 'py3': 0.16; 'read()': 0.16; '16,': 0.16; 'cc:addr:python-list': 0.17; 'cheers,': 0.19; 'header:In- Reply-To:1': 0.21; 'thu,': 0.22; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'received:209.85.161.46': 0.23; 'received:mail- fx0-f46.google.com': 0.23; 'code': 0.24; 'byte': 0.25; 'function': 0.25; 'received:209.85.161': 0.26; 'message-id:@mail.gmail.com': 0.28; 'all,': 0.30; 'cc:addr:python.org': 0.30; 'get.': 0.30; 'someone': 0.33; 'does': 0.33; 'body,': 0.35; 'skip:h 40': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'response': 0.37; 'subject:: ': 0.38; 'received:209': 0.39; 'empty': 0.39; 'requests': 0.39; 'body': 0.61
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=aLLrqxIzr9t4Kys/w+Czcy/HINNk/SKOZ6yHxH1RUA8=; b=hmS3dSs8uNSDcW34LLaYh0h3iWmu3oPmYJ3E3IZRlyIXPIuGQoJ4ulKGKcoB0xvVMi hMAt8iK476EkIoc4JDttsvDiv2xMQsNTBHrHBgoL3x+KXl3+7M8fxJy8DfxrlacbSj1u TOr/aEP7XVlbCi50Bq2HD8Wb/5lLpH4olVaxo=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=OdKq3n6YSEHZYkBK5eCWlbmCvBTqeE6FS/KJox4BNcVxJYGniZARxKYAFiLCSnC6SL 33zCTXLSiqVoqBct//ZUnaUZVrOFocVYIKiPf2oK+3U1VPtZX5ACq0J2aE4djBbY9kbW J0/5eBwFpVba2uZyuJoVJBTygsZ/r9spaaIe0=
MIME-Version 1.0
In-Reply-To <b06bf827-671c-4555-b3ec-108bc5c3a0b8@m10g2000yqd.googlegroups.com>
References <b06bf827-671c-4555-b3ec-108bc5c3a0b8@m10g2000yqd.googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 16 Jun 2011 17:00:57 -0600
Subject Re: HTTPConncetion - HEAD request
To gervaz <gervaz@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
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.44.1308265289.1164.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 82.94.164.166
X-Trace 1308265290 news.xs4all.nl 49181 [::ffff:82.94.164.166]:43665
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7774

Show key headers only | View raw


On Thu, Jun 16, 2011 at 4:43 PM, gervaz <gervaz@gmail.com> 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''

You mean why does it return an empty byte sequence?  Because the HEAD
method only requests the response headers, not the body, so the body
is empty.  If you want to see the response body, use GET.

Cheers,
Ian

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