Skip to content

Commit

Permalink
Add ftpes scheme, and encrypt_mode to ftp/ftps/ftpes
Browse files Browse the repository at this point in the history
  • Loading branch information
SineSwiper committed Aug 23, 2024
1 parent 714b594 commit 0f0681d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/URI/ftp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use parent qw(URI::_server URI::_userpass);

sub default_port { 21 }

sub encrypt_mode { undef }

sub path { shift->path_query(@_) } # XXX

sub _user { shift->SUPER::user(@_); }
Expand Down
10 changes: 10 additions & 0 deletions lib/URI/ftpes.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package URI::ftpes;

require URI::ftp;
@ISA=qw(URI::ftp);

sub secure { 1 }

sub encrypt_mode { 'explicit' }

1;
2 changes: 2 additions & 0 deletions lib/URI/ftps.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ sub default_port { 990 }

sub secure { 1 }

sub encrypt_mode { 'implicit' }

1;
27 changes: 26 additions & 1 deletion t/ftp.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use strict;
use warnings;

use Test::More tests => 13;
use Test::More tests => 23;

use URI ();
my $uri;
Expand All @@ -14,6 +14,10 @@ is($uri->host, "ftp.example.com");

is($uri->port, 21);

is($uri->secure, 0);

is($uri->encrypt_mode, undef);

is($uri->user, "anonymous");

is($uri->password, 'anonymous@');
Expand All @@ -31,10 +35,31 @@ $uri->password("secret");
is($uri, "ftp://gisle%40aas.no:secret\@ftp.example.com/path");

$uri = URI->new("ftp://gisle\@aas.no:secret\@ftp.example.com/path");

is($uri, "ftp://gisle\@aas.no:secret\@ftp.example.com/path");

is($uri->userinfo, "gisle\@aas.no:secret");

is($uri->user, "gisle\@aas.no");

is($uri->password, "secret");

$uri = URI->new("ftps://ftp.example.com/path");

is($uri->scheme, "ftps");

is($uri->port, 990);

is($uri->secure, 1);

is($uri->encrypt_mode, 'implicit');

$uri = URI->new("ftpes://ftp.example.com/path");

is($uri->scheme, "ftpes");

is($uri->port, 21);

is($uri->secure, 1);

is($uri->encrypt_mode, 'explicit');

0 comments on commit 0f0681d

Please sign in to comment.