Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get method sends headers if provided
Fixes #14
- Loading branch information
Showing
3 changed files
with
35 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{ | ||
"perl" : "6.*", | ||
"name" : "LWP::Simple", | ||
"version" : "0.090", | ||
"description" : "LWP::Simple quick & dirty implementation for Rakudo Perl 6", | ||
"depends" : [ "MIME::Base64", "URI" ], | ||
"provides" : { | ||
"perl" : "6.*", | ||
"name" : "LWP::Simple", | ||
"version" : "0.090", | ||
"description" : "LWP::Simple quick & dirty implementation for Rakudo Perl 6", | ||
"depends" : [ "MIME::Base64", "URI" ], | ||
"test-depends" : [ "JSON::Tiny" ], | ||
"provides" : { | ||
"LWP::Simple" : "lib/LWP/Simple.pm" | ||
}, | ||
"author" : "Cosimo Streppone", | ||
"authority" : "perl6", | ||
"source-url" : "git://github.com/perl6/perl6-lwp-simple.git" | ||
"author" : "Cosimo Streppone", | ||
"authority" : "perl6", | ||
"source-url" : "git://github.com/perl6/perl6-lwp-simple.git" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use v6; | ||
use Test; | ||
|
||
use LWP::Simple; | ||
use JSON::Tiny; | ||
|
||
plan 2; | ||
|
||
if %*ENV<NO_NETWORK_TESTING> { | ||
diag "NO_NETWORK_TESTING was set"; | ||
skip-rest("NO_NETWORK_TESTING was set"); | ||
exit; | ||
} | ||
|
||
my %headers = | ||
"Accept" => "application/json", | ||
"User-Agent" => "Perl 6", | ||
; | ||
|
||
my $html = LWP::Simple.get('http://httpbin.org/get', %headers); | ||
my %json = from-json $html; | ||
|
||
is %json<headers><User-Agent>, "Perl 6", "User agent header is sent by GET"; | ||
is %json<headers><Accept>, "application/json", "Accept header is sent by GET"; |