Stas Bekman wrote: > I was trying to get GET, POST and other Apache::TestRequest methods to > accept a pre-existing HTTP::Request object, rather than pass arguments > that will construct one. > > The reason, I was trying to use HTML::TreeBuilder and > HTTP::Request::Form to fill-out a form and submit that, rather than raw > POST, e.g.:
have you tried mech for this? I haven't but have always wanted to http://search.cpan.org/dist/WWW-Mechanize/ > > my $content = get_content($url); > > my $tree = HTML::TreeBuilder->new; > $tree->parse($content); > $tree->eof(); > > my @forms = $tree->find_by_tag_name('form'); > die "What, no forms in $url?" unless @forms; > my $f = HTTP::Request::Form->new($forms[0], $url); > $f->field("foo", $foo); > $f->field("bar", $bar); > my $req = $f->press(); > > and now > > POST $req; can you deconstruct $req into it's parts and use them? ugly, but it may save you the full url issues. > > With the patch below the basic thing works. The issues I've encountered > so far: > - requiring full url, since Apache::TestRequest won't expand it for you) > - redirects aren't handled > - doesn't seem to work with shortcuts like POST_BODY > > The patch simply gives another functionality to the $url argument to any > of the public methods in Apache::TestRequest, to allow an object to be > passed in addition to the string url. > > I'm not sure whether it's worth trying to add this functionality, or > just have the test create its own $UA. yeah, that's the thing. the patch is simple enough, and provided it does't break antything it should be fine. but, really, what is probably more useful is for us to figure out how to get the magic of TestRequest working well with other interesting LWP classes like mech, HTTP::Request::Form, etc glad to see you back with us :) --Geoff