-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix HTTPS by using TLS::Client and fix HTTP/1.1 compat by adding Host…
… header
- Loading branch information
Showing
5 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package Lim::RPC::TLS::Client; | ||
|
||
use common::sense; | ||
use Carp; | ||
|
||
use Log::Log4perl (); | ||
use Scalar::Util qw(weaken); | ||
|
||
use AnyEvent::TLS (); | ||
use Net::SSLeay (); | ||
|
||
use Lim (); | ||
|
||
=encoding utf8 | ||
=head1 NAME | ||
... | ||
=head1 VERSION | ||
See L<Lim> for version. | ||
=cut | ||
|
||
our $VERSION = $Lim::VERSION; | ||
our $INSTANCE; | ||
|
||
=head1 SYNOPSIS | ||
... | ||
=head1 SUBROUTINES/METHODS | ||
=head2 new | ||
=cut | ||
|
||
sub new { | ||
my $this = shift; | ||
my $class = ref($this) || $this; | ||
my $self = { | ||
logger => Log::Log4perl->get_logger($class), | ||
}; | ||
bless $self, $class; | ||
weaken($self->{logger}); | ||
|
||
eval { | ||
$self->{tls_ctx} = AnyEvent::TLS->new(%{Lim::Config->{rpc}->{tls}}); | ||
}; | ||
if ($@) { | ||
Lim::OBJ_DEBUG and $self->{logger}->debug('Unable to initialize TLS context, will not use TLS/SSL: ', $@); | ||
$self->{tls_ctx} = undef; | ||
} | ||
|
||
Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self); | ||
$self; | ||
} | ||
|
||
sub DESTROY { | ||
my ($self) = @_; | ||
Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self); | ||
} | ||
|
||
END { | ||
undef($INSTANCE); | ||
} | ||
|
||
=head2 instance | ||
=cut | ||
|
||
sub instance { | ||
$INSTANCE ||= Lim::RPC::TLS::Client->new; | ||
} | ||
|
||
=head2 tls_ctx | ||
=cut | ||
|
||
sub tls_ctx { | ||
$_[0]->{tls_ctx}; | ||
} | ||
|
||
=head1 AUTHOR | ||
Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >> | ||
=head1 BUGS | ||
Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>. | ||
=head1 SUPPORT | ||
You can find documentation for this module with the perldoc command. | ||
perldoc Lim | ||
You can also look for information at: | ||
=over 4 | ||
=item * Lim issue tracker (report bugs here) | ||
L<https://github.com/jelu/lim/issues> | ||
=back | ||
=head1 ACKNOWLEDGEMENTS | ||
=head1 LICENSE AND COPYRIGHT | ||
Copyright 2012-2013 Jerry Lundström. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the terms of either: the GNU General Public License as published | ||
by the Free Software Foundation; or the Artistic License. | ||
See http://dev.perl.org/licenses/ for more information. | ||
=cut | ||
|
||
1; # End of Lim::RPC::TLS::Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters