[Http-webtest-commits] HTTP-WebTest-Recorder/lib/HTTP/WebTest Recorder.pm,1.7,1.8
Brought to you by:
m_ilya,
richardanderson
From: Ilya M. <m_...@us...> - 2003-02-27 22:00:45
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest In directory sc8-pr-cvs1:/tmp/cvs-serv11813/lib/HTTP/WebTest Modified Files: Recorder.pm Log Message: Refactor recording portion on several methods Index: Recorder.pm =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Recorder.pm 22 Feb 2003 14:36:41 -0000 1.7 --- Recorder.pm 27 Feb 2003 22:00:39 -0000 1.8 *************** *** 56,59 **** --- 56,95 ---- *filter = make_access_method('FILTER', sub { {} }); + sub ui_action { + my $self = shift; + my $request = shift; + + my $ui_path = $self->ui_path; + my($action) = $request->uri->path =~ m|^ /\Q$ui_path\E/(\w+) |x; + + return $action; + } + + sub ui_execute { + my $self = shift; + my %params = @_; + + return $self->controller->execute(recorder => $self, + %params); + } + + sub record { + my $self = shift; + my %params = @_; + + my $is_recording = $self->is_recording; + if($self->filter->{header}) { + while(my($header, $regexp) = each %{$self->filter->{header}}) { + $is_recording &&= $params{response}->header($header) =~ $regexp + if defined $params{response}->header($header); + } + } + + if($is_recording) { + push(@{$self->tests}, + $self->make_test($params{request}, $params{response})); + } + } + # serve web interface and do recording/proxying sub handle { *************** *** 63,85 **** my $ui_path = $self->ui_path; ! if($request->uri->path =~ m|^ /\Q$ui_path\E/(\w+) |x) { # request for recorder web interface ! return $self->controller->execute(recorder => $self, ! action => $1, ! request => $request); } else { # proxy request my $response = $self->user_agent->simple_request($request); ! my $is_recording = $self->is_recording; ! if($self->filter->{header}) { ! while(my($header, $regexp) = each %{$self->filter->{header}}) { ! $is_recording &&= $response->header($header) =~ $regexp ! if defined $response->header($header); ! } ! } ! ! if($is_recording) { ! push @{$self->tests}, $self->make_test($request, $response); ! } return $response; } --- 99,111 ---- my $ui_path = $self->ui_path; ! my $action = $self->ui_action($request); ! if($action) { # request for recorder web interface ! return $self->ui_execute(action => $action, ! request => $request); } else { # proxy request my $response = $self->user_agent->simple_request($request); ! $self->record(request => $request, response => $response); return $response; } |