| 1 | package AnyEvent::FTP::Server::UnambiguousResponseEncoder; | ||||||||||
| 2 | |||||||||||
| 3 | 25 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 25 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 25 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 25 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | # ABSTRACT: Server response encoder that encodes responses so they cannot be confused | ||||||||||
| 9 | 25 | our $VERSION = '0.19'; # VERSION | |||||||||
| 10 | |||||||||||
| 11 | |||||||||||
| 12 | 25 | with 'AnyEvent::FTP::Server::Role::ResponseEncoder'; | |||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | sub encode | ||||||||||
| 16 | { | ||||||||||
| 17 | 819 | ▶ | my $self = shift; | ||||||||
|
Subroutine
encode: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 18 | |||||||||||
| 19 | 819 | my $code; | |||||||||
| 20 | my $message; | ||||||||||
| 21 | |||||||||||
| 22 | 819 | ▶ | if(ref $_[0]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | { | ||||||||||
| 24 | 3 | $code = $_[0]->code; | |||||||||
| 25 | 3 | $message = $_[0]->message; | |||||||||
| 26 | } | ||||||||||
| 27 | else | ||||||||||
| 28 | { | ||||||||||
| 29 | 816 | ($code, $message) = @_; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 819 | ▶ | $message = [ $message ] unless ref($message) eq 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | |||||||||||
| 34 | 819 | my $last = pop @$message; | |||||||||
| 35 | |||||||||||
| 36 | 819 | return join "\015\012", (map { "$code-$_" } @$message), "$code $last\015\012"; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 25 | 1; | |||||||||
| 40 | |||||||||||
| 41 | __END__ | ||||||||||