From b0def23c6bb3a5835643854010780e4a92ee1a0b Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 17 Jul 2011 16:32:30 +0100 Subject: allow changing protocol & realm also, update to work with the standard Mozilla server previously, it only worked against weave-minimal --- lib/DeWeave/Storage.pm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/DeWeave/Storage.pm b/lib/DeWeave/Storage.pm index 70a9368..bcc5c46 100644 --- a/lib/DeWeave/Storage.pm +++ b/lib/DeWeave/Storage.pm @@ -25,6 +25,20 @@ has server_uri => ( default => 'https://weave.thenautilus.net/', ); +has version => ( + isa => Str, + required => 1, + is => 'ro', + default => '1.1', +); + +has basicauth_realm => ( + isa => Str, + required => 1, + is => 'ro', + default => 'Sync', +); + has _useragent => ( init_arg => undef, is => 'ro', @@ -39,7 +53,7 @@ sub _build__useragent { ); $ua->env_proxy; $ua->credentials($self->server_uri->host_port, - 'Weave', + $self->basicauth_realm, $self->username, $self->password); $ua->protocols_allowed(['https']); @@ -50,7 +64,8 @@ sub _build__useragent { sub get_item { my ($self,$path) = @_; - my $relative = sprintf '1.0/%s/%s', + my $relative = sprintf '%s/%s/%s', + $self->version, $self->username,$path; my $uri = URI->new_abs($relative,$self->server_uri); $uri->query_param(full => 1); @@ -61,7 +76,7 @@ sub get_item { return $response->decoded_content; } else { - die $response->status_line; + die "($uri) ".$response->status_line; } } -- cgit v1.2.3