You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by "R. Tyler Ballance" <ty...@monkeypox.org> on 2010/08/26 02:54:06 UTC

Why does the Python client use httplib?

I need HTTP redirect support for the Python RPC library, so I've added it[0]
but the change required dropping httplib in favor of just using urllib2.

I'm wondering if there was any specific reason for using httplib over urllib2
in the first place?

[0] http://github.com/rtyler/avro/tree/1.3.3-redirect

- R. Tyler Ballance
--------------------------------------
  GitHub: http://github.com/rtyler
 Twitter: http://twitter.com/agentdero


Re: Why does the Python client use httplib?

Posted by Ian Kallen <sp...@gmail.com>.
  Perhaps this doesn't have bearing on it's use in avro but as I recall, 
urllib2's redirect handling is braindead.  IIRC, a redirected HEAD 
request gets turned into a a GET; whereas there was no big obstacle in 
homebrewing redirect following on top of httplib (or, wait, was that 
httplib2? sigh).

On 8/25/10 5:54 PM, R. Tyler Ballance wrote:
> I need HTTP redirect support for the Python RPC library, so I've added it[0]
> but the change required dropping httplib in favor of just using urllib2.
>
> I'm wondering if there was any specific reason for using httplib over urllib2
> in the first place?
>
> [0] http://github.com/rtyler/avro/tree/1.3.3-redirect
>
> - R. Tyler Ballance
> --------------------------------------
>    GitHub: http://github.com/rtyler
>   Twitter: http://twitter.com/agentdero
>


-- 
Ian Kallen
blog: http://www.arachna.com/roller/spidaman
tweetz: http://twitter.com/spidaman
vox: 925.385.8426



Re: Why does the Python client use httplib?

Posted by "R. Tyler Croy" <ty...@monkeypox.org>.
On Thu, 26 Aug 2010, Doug Cutting wrote:

> On 08/25/2010 05:54 PM, R. Tyler Ballance wrote:
> >I'm wondering if there was any specific reason for using httplib over urllib2
> >in the first place?
> 
> Not that I know of, and hammer's on vacation.
> 
> >[0] http://github.com/rtyler/avro/tree/1.3.3-redirect
> 
> This is mostly compatible, since the use of httlib or urllib2 is
> hidden within HttpTransceiver.  The only regression is that you
> removed the close() method and that connections are no longer
> reused.  I don't have a strong opinion about whether this is
> acceptable.  One option might be to create a subclass of
> HttpTransceiver that supports redirects but not connection reuse?


I've accounted for your suggestions in the most recent revision of the patch
which I've pushed to:

    http://github.com/rtyler/avro/tree/1.4.0-redirect


I've also attached these changes to the following issue in JIRA:

    https://issues.apache.org/jira/browse/AVRO-665


I honestly don't think there's any gain in "reusing" HTTPConnection objects in
Python but to get this change included as soon as possible, I'd rather just
create a separate class.


- R. Tyler Croy
--------------------------------------
  GitHub: http://github.com/rtyler
 Twitter: http://twitter.com/agentdero


Re: Why does the Python client use httplib?

Posted by Doug Cutting <cu...@apache.org>.
On 08/25/2010 05:54 PM, R. Tyler Ballance wrote:
> I'm wondering if there was any specific reason for using httplib over urllib2
> in the first place?

Not that I know of, and hammer's on vacation.

> [0] http://github.com/rtyler/avro/tree/1.3.3-redirect

This is mostly compatible, since the use of httlib or urllib2 is hidden 
within HttpTransceiver.  The only regression is that you removed the 
close() method and that connections are no longer reused.  I don't have 
a strong opinion about whether this is acceptable.  One option might be 
to create a subclass of HttpTransceiver that supports redirects but not 
connection reuse?

Also, can you please post this as a patch in Jira?

Thanks,

Doug