Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7774
| References | <b06bf827-671c-4555-b3ec-108bc5c3a0b8@m10g2000yqd.googlegroups.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2011-06-16 17:00 -0600 |
| Subject | Re: HTTPConncetion - HEAD request |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.44.1308265289.1164.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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