App-MtAws

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

			bugtracker => 'https://github.com/vsespb/mt-aws-glacier/issues',
			homepage => 'http://mt-aws.com/'
		},
	},
	requires => {
		'perl' => 5.008008, # 5.8.8
		'Config' => 0,

		'LWP' => '5.803', # ancient CentOS 5.x version
		'URI' => '1.10', # even ancient LWP versions require at least 1.10, so we use it too
		'HTTP::Request' => 0, # either shipped with LWP, or prereq by LWP, does not contain correct version, sometimes
		'JSON::XS' => '1',


		# core modules for Perl > 5.8.x
		'Digest::SHA' => 0,

		#
		# CORE MODULES OR DUAL-LIFE MODULES
		#
		'Carp' => 0,

META.json  view on Meta::CPAN

            "Encode" : "0",
            "Exporter" : "5.58",
            "File::Basename" : "0",
            "File::Find" : "0",
            "File::Path" : "0",
            "File::Spec" : "3.12",
            "File::Temp" : "0.16",
            "File::stat" : "0",
            "FindBin" : "0",
            "Getopt::Long" : "2.24",
            "HTTP::Request" : "0",
            "I18N::Langinfo" : "0",
            "IO::Handle" : "0",
            "IO::Pipe" : "0",
            "IO::Select" : "0",
            "JSON::XS" : "1",
            "LWP" : "5.803",
            "List::Util" : "1.11",
            "POSIX" : "0",
            "PerlIO::encoding" : "0",
            "Time::Local" : "0",

META.yml  view on Meta::CPAN

  Encode: 0
  Exporter: 5.58
  File::Basename: 0
  File::Find: 0
  File::Path: 0
  File::Spec: 3.12
  File::Temp: 0.16
  File::stat: 0
  FindBin: 0
  Getopt::Long: 2.24
  HTTP::Request: 0
  I18N::Langinfo: 0
  IO::Handle: 0
  IO::Pipe: 0
  IO::Select: 0
  JSON::XS: 1
  LWP: 5.803
  List::Util: 1.11
  POSIX: 0
  PerlIO::encoding: 0
  Time::Local: 0

lib/App/MtAws/GlacierRequest.pm  view on Meta::CPAN


our $VERSION = '1.120';

use strict;
use warnings;
use utf8;
use POSIX;
use LWP 5.803;
use LWP::UserAgent;
use URI::Escape;
use HTTP::Request;
use Digest::SHA qw/hmac_sha256 hmac_sha256_hex sha256_hex/;
use App::MtAws::MetaData;
use App::MtAws::Utils;
use App::MtAws::Exceptions;
use App::MtAws::HttpSegmentWriter;
use App::MtAws::SHAHash qw/large_sha256_hex/;
use Carp;

sub new
{

lib/App/MtAws/GlacierRequest.pm  view on Meta::CPAN

		$url = $self->{protocol} ."://$ENV{MTGLACIER_FAKE_HOST}$self->{url}" if $ENV{MTGLACIER_FAKE_HOST};
		if ($self->{protocol} eq 'https') {
			if ($ENV{MTGLACIER_FAKE_HOST}) {
				$ua->ssl_opts( verify_hostname => 0, SSL_verify_mode=>0); #Hostname mismatch causes LWP to error.
			} else {
				$ua->ssl_opts( verify_hostname => 1, SSL_verify_mode=>1);
			}
		}
		$url .= "?$self->{params_s}" if $self->{params_s};
		if ($self->{method} eq 'PUT') {
			$req = HTTP::Request->new(PUT => $url, undef, $self->{dataref});
		} elsif ($self->{method} eq 'POST') {
			if ($self->{dataref}) {
				$req = HTTP::Request->new(POST => $url, [Content_Type => 'form-data'], ${$self->{dataref}});
			} else {
				$req = HTTP::Request->new(POST => $url );
			}
		} elsif ($self->{method} eq 'DELETE') {
			$req = HTTP::Request->new(DELETE => $url);
		} elsif ($self->{method} eq 'GET') {
			$req = HTTP::Request->new(GET => $url);
		} else {
			confess;
		}
		for ( @{$self->{headers}}, @{$self->{req_headers}} ) {
			$req->header( $_->{name}, $_->{value} );
		}
		my $resp = undef;

		my $t0 = time();
		if ($self->{content_file} && $self->{writer}) {

t/integration/lwp.t  view on Meta::CPAN

	}

	sub httpd_quit
	{
		my($c) = @_;
		$c->send_error(503, "Bye, bye");
		exit;  # terminate HTTP server
	}

	my $ua = new LWP::UserAgent;
	my $req = new HTTP::Request GET => "$proto://$base/quit";
	my $resp = $ua->request($req);

sub initialize_processes
{
	if (@ARGV && $ARGV[0] eq 'daemon') {
		my $d = $proto eq 'http' ?
			HTTP::Daemon->new(Timeout => 20, LocalAddr => '127.0.0.1') :
			HTTP::Daemon::SSL->new(Timeout => 20, LocalAddr => '127.0.0.1'); # need certs/ dir
		$SIG{PIPE}='IGNORE';
		$| = 1;

t/integration/lwp.t  view on Meta::CPAN

		print STDERR "HTTP Server terminated (errno=$errno_i [$errno_s])\n";
		exit;
	} else {
		use Config;
		my $perl = $Config{'perlpath'};
		open(DAEMON, "'$perl' $0 daemon |") or die "Can't exec daemon: $!";
		my $greeting = <DAEMON>;
		$greeting =~ m!<URL:https?://([^/]+)/>! or die;
		my $base = $1;
		require LWP::UserAgent;
		require HTTP::Request;
		require App::MtAws::GlacierRequest;
		require App::MtAws;
		return $base;
	}
}

1;



( run in 0.654 second using v1.01-cache-2.11-cpan-de7293f3b23 )