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

Owner: Nobody in particular
Requestors: perl [...]

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


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: And I also found some more in-depth discussion of the issue: 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.
text/x-diff 670b
--- 2003-07-24 17:24:05.000000000 +0000 +++ 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 infrastructure.

Please report any issues with to