[Http-webtest-general] Re: last_test HTTP-WebTest-1.99_09
Brought to you by:
m_ilya,
richardanderson
From: Kevin B. <ke...@ri...> - 2002-11-04 16:43:25
|
Hi sorry for the late reply, been on leave... I'm trying to get access to the value on the cookie returned since I need know the cookie value to set as a param in a subsequent call So I run one web test to get the cookie and then extract it from the last_response and then run some more tests. my $wt = HTTP::WebTest->new; # run tests to get cookie $wt->run_tests([{...}]); # get cookie returns an array ref of the cookie my ($cookie) = get_cookie($wt->last_response); # run more tests $wt->run_tests([{ ... param => { sid => $cookie->[2] }, # using cookie value here in call cookies => [ $cookie ] ... } ]); sub get_cookies { my $response = shift; # parse cookies in response use HTTP::Cookies; my $cookie_jar = HTTP::Cookies->new; $cookie_jar->extract_cookies($response); # suck cookies out of cookie jar via scan my @cookies; $cookie_jar->scan(sub {push @cookies, [@_]}); @cookies } Unless you can see an easier way to accomplish this. * Ilya Martynov <il...@ma...> [2002-10-18 19:58:33 +0400]: > >>>>> On Fri, 18 Oct 2002 15:41:28 +0200, Kevin Baker <ke...@ri...> said: > > KB> Hi, > > Hi Kevin, > > KB> I was trying to get the last_response from HTTP::WebTest > KB> but it was always returning undef. > > KB> Looking at run_tests I suspect that there is a bug with the > KB> final setting of last_test. The last call to last_test sets > KB> it to undef. > > It is not a bug, it is a feature :). I didn't though that anybody > would use last_xxx methods after running tests (note that you can > always get to last test results via ${$webtest->tests}[-1]->response). > I supposed that these methods would be used during test runtime (for > example in plugins). > > Well, having said this I should admit that I don't really see why it > should be forbiden to use these methods after running tests and I > can't recall why I explictly forbid it. So I'm going to apply your > patch unless I recall any special reason why it is wrong. > > Thanks for your patch anyway. > > -- > Ilya Martynov, il...@ip... > CTO IPonWEB (UK) Ltd > Quality Perl Programming and Unix Support > UK managed @ offshore prices - http://www.iponweb.net > Personal website - http://martynov.org -- Kevin Baker RIPE NCC |