Skip to content

Commit

Permalink
Merge pull request #690 from hplato/nanoleaf_aurora
Browse files Browse the repository at this point in the history
Nanoleaf aurora support
  • Loading branch information
hplato authored May 30, 2017
2 parents 8f9296d + 320f38c commit 2d975ce
Show file tree
Hide file tree
Showing 2 changed files with 1,291 additions and 4 deletions.
38 changes: 34 additions & 4 deletions bin/get_url
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ my ( %config_parms, %parms );
use Getopt::Long;

#print "get_url: @ARGV\n";
if ( !&GetOptions( \%parms, 'h', 'help', 'quiet', 'cookies=s', 'cookie_file_in=s', 'cookie_file_out=s', 'post=s', 'header=s', 'userid=s', 'password=s' )
if (
!&GetOptions( \%parms, 'h', 'help', 'quiet', 'cookies=s', 'cookie_file_in=s', 'cookie_file_out=s', 'post=s', 'header=s', 'userid=s', 'password=s', 'ua',
'put=s', 'json', 'response_code' )
or !@ARGV
or $parms{h}
or $parms{help} )
or $parms{help}
)
{

print <<eof;
Expand All @@ -42,10 +45,19 @@ Usage:
-userid 'userid' : Use these 2 parms if your web page is protected by
-password 'password': 'basic credentials' (i.e. you get a browser popup).
-post 'poststr': Makes this a post request with the specified name/value pairs
-post 'poststr': Makes this a POST request with the specified name/value pairs
as the form data, such as: 'name1=val1&name2=val2'
-put 'putstr': Makes this a PUT request with the specified name/value pairs
as the form data, such as: 'name1=val1&name2=val2'
-json: Changes content_type to ('application/json')
-ua: use UserAgent
-header 'header_file': HTTP headers from the server are stored in this file
-response_code: STDOUT only: Prepend output with RESPONSECODE: <response code>\n
If local_file is specified, data is stored there.
Expand Down Expand Up @@ -73,8 +85,10 @@ $parms{cookies} = &file_read( $parms{cookie_file_in} )

if ( ( $config_parms{get_url} eq 'useragent' )
or $parms{post}
or $parms{put}
or $parms{header}
or $parms{cookies}
or $parms{ua}
or $parms{cookie_file_out}
or $parms{password} )
{
Expand Down Expand Up @@ -105,9 +119,24 @@ sub use_ua {
my $request;
if ( $parms{post} ) {
$request = new HTTP::Request( 'POST' => $url );
$request->content_type('application/x-www-form-urlencoded');
if ( $parms{json} ) {
$request->content_type('application/json');
}
else {
$request->content_type('application/x-www-form-urlencoded');
}
$request->content( $parms{post} );
}
elsif ( $parms{put} ) {
$request = new HTTP::Request( 'PUT' => $url );
if ( $parms{json} ) {
$request->content_type('application/json');
}
else {
$request->content_type('application/x-www-form-urlencoded');
}
$request->content( $parms{put} );
}
else {
$request = new HTTP::Request( 'GET', $url );
}
Expand Down Expand Up @@ -153,6 +182,7 @@ sub use_ua {
}
else {
$response = $ua->request($request);
print "RESPONSECODE:" . $response->code() . "\n" if ( $parms{response_code} );
print $response->content();
}
if ( $response->is_error() ) {
Expand Down
Loading

0 comments on commit 2d975ce

Please sign in to comment.