Live data from Hacker News

Python Requests: HTTP for Humans

python-requests.org

41–50 of 86 posts

Re: Python Requests: HTTP for Humans

#41
post #39

I note that you call gevent.monkey.patch_all() in async. I'm still fairly new to gevent and I'm curious if others consider this good style for a library?

If you're using Twisted (or Tornado, ugh) then there are builtin HTTP clients which are async in all the right ways and provide similar high-level APIs for making requests. If you're using gevent, then this is what you want. If you're using eventlet, you should switch to gevent or learn Twisted.

So yeah, this is suboptimal, but not the worst thing in the world. It should really be documented though.

Re: Python Requests: HTTP for Humans

#42

Absolutely my favourite recent development in the Python world. I won't be mistaken if I say that many of us have built half-arse versions of this on top of urllib(2) multiple times in the past. :-) The support for keep-alive is particularly welcome, huge kudos to the author. Question to users of other languages: do equivalents exist for PHP, Perl, C# or Java? Ruby folks rave about restclient, but is there anything e…

C# / .NET had System.Net.WebRequest since 1.1. It's similar in principle to Requests.

No, no it's not. (Http)WebRequest IS AWFUL. I built RestSharp because HWR is so bad. WebClient is closer to requests, but still horribly awful if you know anything about HTTP.

The new System.Net.Http.HttpClient in .NET 4.5 is closer to Requests and not entirely bad, if a little rigid.

Re: Python Requests: HTTP for Humans

#43
post #42

Earlier quoted context omitted.

C# / .NET had System.Net.WebRequest since 1.1. It's similar in principle to Requests.

No, no it's not. (Http)WebRequest IS AWFUL. I built RestSharp because HWR is so bad. WebClient is closer to requests, but still horribly awful if you know anything about HTTP. The new System.Net.Http.HttpClient in .NET 4.5 is closer to Requests and not entirely bad, if a little rigid.

Just out of curiosity, what's so awful about WebRequest? I've been using it for years for various things and never really had a problem with it.

Re: Python Requests: HTTP for Humans

#44

Looks like Python got something similar to Perl's LWP https://metacpan.org/module/LWP

I think LWP is more equivalent to Python's urllib2 (ie. both big beasts!). So this i believe is closer to what LWP::UserAgent ( https://metacpan.org/module/LWP::UserAgent ) does. Also check out Mojo::UserAgent ( https://metacpan.org/module/Mojo::UserAgent ) for a nice(er) alternative. And don't forget that Perl now comes a nice lightweight alternative as standard: https://metacpan.org/module/HTTP::Tiny

Yes gp, LWP::UserAgent specifically. Never knew about HTTP::Tiny thanks.. I'll check it out.

Re: Python Requests: HTTP for Humans

#45
post #20

Absolutely my favourite recent development in the Python world. I won't be mistaken if I say that many of us have built half-arse versions of this on top of urllib(2) multiple times in the past. :-) The support for keep-alive is particularly welcome, huge kudos to the author. Question to users of other languages: do equivalents exist for PHP, Perl, C# or Java? Ruby folks rave about restclient, but is there anything e…

For Ruby there's httparty, https://github.com/jnunemaker/httparty , curb, and a couple of others that escape me right now.

Also Typhoeus and RestClient.

Probably others.

Re: Python Requests: HTTP for Humans

#47
If Python is going to include urllib or urllib2 in the standard distro, why not make it good? Http is foundational to (web) programming. I am shocked at how poor the standard httpclient implementations are in most environments.

Re: Python Requests: HTTP for Humans

#48
post #22
post #20

Earlier quoted context omitted.

For Ruby there's httparty, https://github.com/jnunemaker/httparty , curb, and a couple of others that escape me right now.

Here's the new one I'm working on: https://github.com/tarcieri/http httparty does a few of the same tricks, but I still find its API a bit obtrusive. At least it automatically parses JSON! (my library does this too, if an appropriate library is loaded) In addition to a humane interface, it will soon be backed by a Ragel-generated HTTP parser: https://github.com/tarcieri/http/tree/master/parser

Did you get to re-use any of Zed Shaw's excellent parser work from Mongrel?

Re: Python Requests: HTTP for Humans

#49

Absolutely my favourite recent development in the Python world. I won't be mistaken if I say that many of us have built half-arse versions of this on top of urllib(2) multiple times in the past. :-) The support for keep-alive is particularly welcome, huge kudos to the author. Question to users of other languages: do equivalents exist for PHP, Perl, C# or Java? Ruby folks rave about restclient, but is there anything e…

I always use libcurl for PHP... don't really have any complaints.

Re: Python Requests: HTTP for Humans

#50
post #22
post #20

Earlier quoted context omitted.

For Ruby there's httparty, https://github.com/jnunemaker/httparty , curb, and a couple of others that escape me right now.

Here's the new one I'm working on: https://github.com/tarcieri/http httparty does a few of the same tricks, but I still find its API a bit obtrusive. At least it automatically parses JSON! (my library does this too, if an appropriate library is loaded) In addition to a humane interface, it will soon be backed by a Ragel-generated HTTP parser: https://github.com/tarcieri/http/tree/master/parser

Looks very promising. I see it currently uses Net::HTTP under the hood - do you plan to keep it that way, like Httparty and Faraday, or are you going to do away with Net::HTTP altogether? (The comment saying "this is temporary" next to requiring 'net/https' is encouraging... :))
Post reply on HN