Permalink
Browse files

Fetch account from the URI

  • Loading branch information...
1 parent 420e5e0 commit 5179b7c13979b89d022dc7f05ef5886199dbda6a @acme committed Jan 9, 2012
Showing with 7 additions and 7 deletions.
  1. +6 −4 lib/Net/Azure/BlobService.pm
  2. +1 −3 play.pl
@@ -5,9 +5,8 @@ use Digest::SHA qw(hmac_sha256_base64);
use MIME::Base64;
use Moose;
-has 'account' => ( is => 'ro', isa => 'Str', required => 1 );
has 'primary_access_key' => ( is => 'ro', isa => 'Str', required => 1 );
-has 'user_agent' => (
+has 'user_agent' => (
is => 'ro',
isa => 'LWP::UserAgent',
default => sub {
@@ -20,6 +19,9 @@ has 'user_agent' => (
sub sign_http_request {
my ( $self, $http_request ) = @_;
+ my $host = $http_request->uri->host;
+ my ($account) = $host =~ /^(.+?)\./;
+
$http_request->header( ':x-ms-version', '2011-08-18' );
$http_request->header( 'Date', time2str() );
$http_request->content_length( length $http_request->content );
@@ -29,7 +31,7 @@ sub sign_http_request {
sort grep {/^:x-ms/i} $http_request->header_field_names;
my $canonicalized_resource
- = '/' . $self->account . $http_request->uri->path . join "", map {
+ = '/' . $account . $http_request->uri->path . join "", map {
"\n"
. lc($_) . ':'
. join( ',', sort $http_request->uri->query_param($_) )
@@ -56,7 +58,7 @@ sub sign_http_request {
$signature .= '=';
$http_request->header( 'Authorization',
- "SharedKey " . $self->account . ":" . $signature );
+ "SharedKey " . $account . ":" . $signature );
return $http_request;
}
View
@@ -17,9 +17,7 @@
= 'XXX';
my $blobservice = Net::Azure::BlobService->new(
- account => $account,
- primary_access_key => $primary_access_key
-);
+ primary_access_key => $primary_access_key );
# Get Blob Service Properties
my $uri = URI->new("https://$account.blob.core.windows.net/");

0 comments on commit 5179b7c

Please sign in to comment.