| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package AnyEvent::FTP::Server::Connection; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 25 |  |  | 25 |  | 256485 | use strict; | 
|  | 25 |  |  |  |  | 75 |  | 
|  | 25 |  |  |  |  | 866 |  | 
| 4 | 25 |  |  | 25 |  | 146 | use warnings; | 
|  | 25 |  |  |  |  | 57 |  | 
|  | 25 |  |  |  |  | 733 |  | 
| 5 | 25 |  |  | 25 |  | 578 | use 5.010; | 
|  | 25 |  |  |  |  | 99 |  | 
| 6 | 25 |  |  | 25 |  | 743 | use Moo; | 
|  | 25 |  |  |  |  | 13085 |  | 
|  | 25 |  |  |  |  | 381 |  | 
| 7 | 25 |  |  | 25 |  | 21589 | use AnyEvent::FTP::Request; | 
|  | 25 |  |  |  |  | 77 |  | 
|  | 25 |  |  |  |  | 9511 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | # ABSTRACT: FTP Server connection class | 
| 10 |  |  |  |  |  |  | our $VERSION = '0.17'; # VERSION | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | with 'AnyEvent::FTP::Role::Event'; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | __PACKAGE__->define_events(qw( request response close )); | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | has context => ( | 
| 17 |  |  |  |  |  |  | is       => 'ro', | 
| 18 |  |  |  |  |  |  | required => 1, | 
| 19 |  |  |  |  |  |  | ); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | has response_encoder => ( | 
| 22 |  |  |  |  |  |  | is => 'ro', | 
| 23 |  |  |  |  |  |  | lazy => 1, | 
| 24 |  |  |  |  |  |  | default => sub { | 
| 25 |  |  |  |  |  |  | require AnyEvent::FTP::Server::UnambiguousResponseEncoder; | 
| 26 |  |  |  |  |  |  | AnyEvent::FTP::Server::UnambiguousResponseEncoder->new; | 
| 27 |  |  |  |  |  |  | }, | 
| 28 |  |  |  |  |  |  | ); | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | has ip => ( | 
| 31 |  |  |  |  |  |  | is       => 'ro', | 
| 32 |  |  |  |  |  |  | required => 1, | 
| 33 |  |  |  |  |  |  | ); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | sub process_request | 
| 36 |  |  |  |  |  |  | { | 
| 37 | 677 |  |  | 677 | 1 | 11639 | my($self, $line) = @_; | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 677 |  |  |  |  | 1381 | my $raw = $line; | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 677 |  |  |  |  | 2660 | $self->emit(request => $raw); | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 677 |  |  |  |  | 1676 | $line =~ s/\015?\012//g; | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 677 | 50 |  |  |  | 3714 | if($line =~ s/^([A-Z]{1,4})\s?//i) | 
| 46 |  |  |  |  |  |  | { | 
| 47 | 677 |  |  |  |  | 5577 | $self->context->push_request($self, AnyEvent::FTP::Request->new(uc $1, $line, $raw)); | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  | else | 
| 50 |  |  |  |  |  |  | { | 
| 51 | 0 |  |  |  |  | 0 | $self->context->invalid_syntax($self, $raw); | 
| 52 |  |  |  |  |  |  | } | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 677 |  |  |  |  | 3484 | $self; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub send_response | 
| 58 |  |  |  |  |  |  | { | 
| 59 | 813 |  |  | 813 | 1 | 3876 | my $self = shift; | 
| 60 | 813 |  |  |  |  | 20658 | my $raw = $self->response_encoder->encode(@_); | 
| 61 | 813 |  |  |  |  | 3418 | $self->emit(response => $raw); | 
| 62 | 813 |  |  |  |  | 3509 | $self; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | sub close | 
| 66 |  |  |  |  |  |  | { | 
| 67 | 80 |  |  | 80 | 1 | 206 | my($self) = shift; | 
| 68 | 80 |  |  |  |  | 286 | $self->emit('close'); | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | 1; | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | __END__ |