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 else?
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 else?
use Mojo::UserAgent;
print Mojo::UserAgent->new->get('http://freegeoip.net/json/8.8.8.8')->res->json->{country_name};
Very powerful.Also check out the command line interface which allows you todo things like this:
$ mojo get http://mojolicio.us 'head > title'
ref: http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Comm...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:
Carl is working on a comprehensive event-driven HTTP (and Websockets) framework for Clojure. I'm just borrowing his parser and re-wrapping it in Ruby. I prefer to use Carl's as he's (at least for now) actively maintaining it, as opposed to using Zed's abandonware.
Probably others.
I do have a half-baked implementation on urllib2 that I hate. This is really cool.
The new System.Net.Http.HttpClient in .NET 4.5 is closer to Requests and not entirely bad, if a little rigid.
And this one is a pet peeve, but I hate that verbose stateful OO idiom where you instantiate an object (with a factory) and then use setters to change properties, instead of setting it all in a single command. I don't know if other .NET HTTP libraries change that, though...
- It's too low level for quick stuff
- It handles HTTP basic auth wrong
- It throws an exception, AN EXCEPTION, for any response that isn't 2xx
- Async is an ugly mess
- In love with streams
- Horribly inconsistent across framework profiles
- ServicePointManager.Expect100Continue
- Inconsistent header handling and restrictions
- Terrible cookie APISo's python's urllib2, the point of `request` is that as soon as you go even slightly beyond very basic GET and POST, it breaks down quickly in a horrible mess.
I'm still surprised every time I use it that they've not released a modern library for it in .Net.