[MERGE] http+pycurl supports redirects

John Arbash Meinel john at arbash-meinel.com
Wed Jul 19 04:05:11 BST 2006

Hash: SHA1

Michael Ellerman wrote:


> Thanks for fixing it up, I haven't had the time lately. 

No problem. I'm pretty excited to see it come in.


> I don't understand what "body_is_header" is for, we only ever want the
> headers associated with the final response don't we?

I just made it optional, in case we found something different.

> I also wonder if it should be a little stricter, and look for
> "\r\n\r\nHTTP" as the sign that a new set of headers is starting? I
> also think it should be a loop so we can handle a double/triple
> redirect.

Actually, it is recursive. So it will handle as many as it needs to.

I don't know if we want to be 100% strict about requiring '\r\n'. I
would be okay with '\n' or '\r\n'.
We could be more strict and require response.startswith('HTTP'). By the
time we get there, the '\r\n' has already been consumed by the rfc822

> +    def test_redirect_body_is_body(self):
> +        """Check that we parse the right portion if body_is_header is
> True"""
> +        self.use_response(_redirect_response, body_is_header=False)
> +        self.assertRaises(KeyError, self.headers.__getitem__,
> 'Content-Range')
> +        self.check_header('Content-Type', 'text/html; charset=iso-8859-1')
> +        self.check_header('Location',
> +           
> 'http://bazaar-vcs.org/bzr/bzr.dev/.bzr/repository/inventory.knit')
> The docstring mentions body_is_header=True, but then you pass False ?

Thanks for catching the bogus docstring. I'll fix it up.

Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the bazaar mailing list