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: 3053
Status: resolved
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: perl [...] ken.nsds.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.50
Fixed in: (no value)

Attachments


Subject: redirect POST->GET should remove content
Download (untitled) / with headers
text/plain 1.3k
Using: Perl v5.8.0 on Debian GNU/Linux (kernel 2.4.20). In version 0.50 and later, Mech was updated to "do what most browsers do when they handle a redirect: It changes the POST to a GET". However, it was not updated to also remove the POSTed content from the request. Attached is a patch that does this. I am working on a robot to interface to yahoo's briefcase (to upload files, etc.) and I found a couple places where it does a redirect after a POST and expects the browser to do a GET with *no content*. I got an error message from LWP that "peer prematurely closed connection" (or something link that) because the server closed the connection right after the GET request headers were received and before the content was sent. Therefore, I think it is the right thing to do to remove the content. For precedence, I did a little research on the internet and found an article where someone described this particular behavior of browsers: http://groups.google.com/groups?q=POST+GET+redirect+content&hl=en&lr=&ie=UTF-8&selm=7infrd%24hm6%40netline.jpl.nasa.gov&rnum=7 And I also found some more in-depth discussion of the issue: http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html Thank you very much for writing such a great module and keeping it up to date. It has made it much easier to write this robot. Let me know if you need me to do anything else to help solve this issue.
Download Mechanize.pm.diff
text/x-diff 670b
--- Mechanize.orig.pm 2003-07-24 17:24:05.000000000 +0000 +++ Mechanize.pm 2003-07-27 23:04:49.000000000 +0000 @@ -950,8 +950,13 @@ if ( $ok ) { $self->{redirected_uri} = $prospective_request->uri; - # Mimic erroneous browser behaviour by changing the method. - $prospective_request->method("GET") if $prospective_request->method eq "POST"; + if ( $prospective_request->method eq "POST" ) { + # Mimic erroneous browser behaviour by changing the method + # and removing content. + $prospective_request->method("GET"); + $prospective_request->content(""); + $prospective_request->remove_header("Content-Length"); + } } return $ok;
Download (untitled) / with headers
text/plain 156b
Have you looked at the recent Mech 0.70 that requires the new LWP? Gisle did some magic finagling on redirects. Let me know if that solves your problem.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.