Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created October 5, 2010 14:01
Show Gist options
  • Save sharifulin/611589 to your computer and use it in GitHub Desktop.
Save sharifulin/611589 to your computer and use it in GitHub Desktop.
LWP::UserAgent vs. Mojo::Client
use Mojo::Client;
use LWP::UserAgent;
use Test::More tests => 6;
my $r;
$r = LWP::UserAgent->new->post(
'http://post.audioscrobbler.com/2.0/',
'Content-Type' => 'application/x-www-form-urlencoded',
'Content' => 'api_key=5dda3034ad322e997a40146a29f4df83&api_sig=480559c6048525596cebc7b2fd2437b6&artist=Prince+Rama&method=User.updateNowPlaying&sk=3b32ac7fcf2e9b5ee33de6100745c51e&track=Lightening+Fossil',
);
# warn $r->as_string;
is $r->code, 200;
is $r->headers->header('Content-Length'), undef;
is length $r->content, 158, 'LWP::UserAgent is OK';
#
$r = Mojo::Client->new->post(
'http://post.audioscrobbler.com/2.0/',
{'Content-Type' => 'application/x-www-form-urlencoded'},
'api_key=5dda3034ad322e997a40146a29f4df83&api_sig=480559c6048525596cebc7b2fd2437b6&artist=Prince+Rama&method=User.updateNowPlaying&sk=3b32ac7fcf2e9b5ee33de6100745c51e&track=Lightening+Fossil',
)->res;
# warn $r;
is $r->code, 200;
is $r->headers->header('Content-Length'), undef;
is length $r->body, 158, 'Mojo::Client is OK';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment