pplu / aws-sdk-perl

A community AWS SDK for Perl Programmers
Other
171 stars 94 forks source link

Support HTTPS Proxy #42

Closed dtikhonov closed 9 years ago

dtikhonov commented 9 years ago

At $WORK, I develop on machines that sit behind an HTTP and HTTPS proxy -- no direct access to internet is allowed. HTTP::Tiny does not support HTTPS proxies.

I was able to get Paws to do what I want by switching to LWP::UserAgent: https://github.com/dtikhonov/aws-sdk-perl/commit/15e8941cf8ab1c6de6cd7164930238b8bda38eff, but I am not sure how to do this correctly.

https://github.com/pplu/aws-sdk-perl/pull/7 does something in this area, but the code has changed significantly since then.

pplu commented 9 years ago

Great work!

What you've is on the right track :) What would you think about renaming your Paws::Net::Caller to Paws::Net::LWPCaller?

Callers are pluggable, so you can do the following:

my $paws = Paws->new(config => { caller => 'Paws::Net::LWPCaller' });
$paws->service('EC2')->DescribeInstances;

In the code, there is the intention to be able to globally set defaults for all objects, but due to not having tests for that functionality, it was broken while refactoring. I've just pushed c93f8c1ef3691194a418f1d21adf7d3deebe8715, so that you can do this:

use Paws;
Paws->default_config->caller('Paws::Net::OtherCaller');

# Called with OtherCaller
my $i = Paws->service('EC2', region => 'eu-west-1')->DescribeInstances;

my $paws = Paws->new;
# Called with OtherCaller too..
$paws->service('EC2', region => 'eu-west-1')->DescribeInstances);

Do you think this is a good way of supporting custom callers?

dtikhonov commented 9 years ago

This works, I tested by adding the following line to examples/iam.pl

Paws->default_config->caller('Paws::Net::LWPCaller');
pplu commented 9 years ago

Paws 0.14 is on CPAN with LWPCaller bundled :)