Pootle-Client

 view release on metacpan or  search on metacpan

lib/Pootle/Agent.pm  view on Meta::CPAN

  my $proto = $response->protocol;
  $status_line = "$proto $status_line" if $proto;
  return join("\n", $status_line, $response->headers_as_string("\n"),''); #Includes empty line to signal the start of HTTP payload
}

sub _loadCredentials($s) {
  my $c = $s->credentials();
  my $credentialsConfirmed;
  my $file;
  if (-e $c) { #This is a file
    $file = $c;
    $l->info("Loading credentials from file '$c'");
    my @rows = File::Slurp::read_file( $c => { binmode => ':encoding(UTF-8)' } );
    foreach my $row (@rows) {
      if ($row =~ /^(.+):(.+)$/) {
        $credentialsConfirmed = "$1:$2";
      }
      last;
    }
  }
  else {
    $credentialsConfirmed = $c;
  }

  unless ($credentialsConfirmed && $credentialsConfirmed =~ /^(.+):(.+)$/) {
    Pootle::Exception::Credentials->throw(error => "_loadCredentials():> Given credentials ".($file ? "from file '$file' " : "")."are malformed. Credentials must look like username:password, or point to a file with properly formatted credentials.");
  }
  return $credentialsConfirmed;
}

##########    ###   ###
 ## ACCESSORS  ###   ###
##########    ###   ###

=head2 baseUrl

 @RETURNS String, the full url of the Pootle server we are interfacing with, eg. https://translate.koha-community.org

=cut

sub baseUrl($s) {
  return $s->{baseUrl};
}

=head2 credentials

 @RETURNS String, username:password

=cut

sub credentials($s) {
  return $s->{credentials};
}

=head2 ua

 @RETURNS L<LWP::UserAgent>

=cut

sub ua($s) { return $s->{ua} }

1;



( run in 2.165 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )