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: 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: References: From: Ian Kelly Date: Thu, 16 Jun 2011 17:00:57 -0600 Subject: Re: HTTPConncetion - HEAD request To: gervaz 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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'' 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