Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 2152
Status: resolved
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: casey [...] geeknest.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Better async support.
Currently you can intercept the actual request phase with a sub-class overriding _do_request(). This is nice, but not quite nice enough. The request phase needs to be broken into two distinct parts: preparing the request and parsing the response. _do_request() would wrap both of these phases and therefore keep current functionality. Two new methods would need to be added, something like: _prepare_req(), and _parse_res(). They would return an HTTP::Request object, and take an HTTP::Response object respectivley. This allows an outside program to do the real HTTP interaction, for instance, POE::Component::Client::HTTP. Thinking about this more, there is a good chance that _prepare_req() and _parse_res() should be public methods, so no underscore is required. My program would effectivley do something like the following, instead of call get(): my $req = $agent->prepare_req( 'http://example.com' ); # do the requesting, populate HTTP::Response... $agent->parse_res( $res );
Show quoted text
> Currently you can intercept the actual request phase with a sub-class > overriding _do_request(). This is nice, but not quite nice enough. > The request phase needs to be broken into two distinct parts: > preparing the request and parsing the response. _do_request() > would wrap both of these phases and therefore keep current > functionality. > > Two new methods would need to be added, something like: > _prepare_req(), and _parse_res(). They would return an > HTTP::Request object, and take an HTTP::Response object > respectivley. This allows an outside program to do the real HTTP > interaction, for instance, POE::Component::Client::HTTP. > > Thinking about this more, there is a good chance that _prepare_req() > and _parse_res() should be public methods, so no underscore is > required. > > My program would effectivley do something like the following, instead > of call get(): > > my $req = $agent->prepare_req( 'http://example.com' ); > # do the requesting, populate HTTP::Response... > $agent->parse_res( $res );
_do_request() is now implemented entirely with proper LWP::UserAgent methods, including prepare_request() et al. That should make things better, yes?