Created
August 18, 2016 16:58
-
-
Save lindleyw/19052f7a91103ad353f38f2f5deb44b6 to your computer and use it in GitHub Desktop.
Example patch for handling only known protocols
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
diff --git a/lib/Mojo/UserAgent.pm b/lib/Mojo/UserAgent.pm | |
index ebe9537..25f2160 100644 | |
--- a/lib/Mojo/UserAgent.pm | |
+++ b/lib/Mojo/UserAgent.pm | |
@@ -84,18 +84,19 @@ sub _connect { | |
if (my $local = $self->local_address) { $options{local_address} = $local } | |
$options{handle} = $handle if $handle; | |
- # SOCKS | |
- if ($proto eq 'socks') { | |
+ if ($proto eq 'socks') { # SOCKS | |
@options{qw(socks_address socks_port)} = @options{qw(address port)}; | |
($proto, @options{qw(address port)}) = $t->endpoint($tx); | |
my $userinfo = $tx->req->via_proxy(0)->proxy->userinfo; | |
@options{qw(socks_user socks_pass)} = split ':', $userinfo if $userinfo; | |
+ } elsif ($proto eq 'https') { # TLS | |
+ $options{tls} = 1; | |
+ map { $options{"tls_$_"} = $self->$_ } qw(ca cert key); | |
+ } elsif ($proto ne 'http') { # invalid unless HTTP | |
+ $self->_error(undef, 'Invalid protocol'); | |
+ return undef; | |
} | |
- # TLS | |
- map { $options{"tls_$_"} = $self->$_ } qw(ca cert key) | |
- if ($options{tls} = $proto eq 'https'); | |
- | |
weaken $self; | |
my $id; | |
return $id = $loop->client( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment