Subject: | "Unexpected Field Value" when using Mechanize::follow_link() |
Date: | Thu, 20 May 2004 17:07:24 -0400 |
From: | "Haimov, Eugene" <EHaimov [...] seic.com> |
To: | <bug-WWW-Mechanize [...] rt.cpan.org.> |
--------------------------
MODULE VERSION:
--------------------------
Version 0.48
$Header: /cvsroot/www-mechanize/www-mechanize/lib/WWW/Mechanize.pm,v
1.13 2003/06/22 18:46:56 petdance Exp $
--------------------------
SYMPTOM:
--------------------------
"Unexpected Field Value" error is reported when using
Mechanize::follow_link() method.
ROOT CAUSE:
Mechanize::request() method sets the "Referer" header for the underlying
request object using this code:
$request->header( Referer => $self->{last_uri} ) if
$self->{last_uri};
However, the $self->{last_uri} happens to be a ref to the object of type
'URI::http',
This is then being passed to Headers.pm method _header(). There, the
$val variable
if checked to be either !ref($val), or ref($val)=='ARRAY', neither of
which is the case.
--------------------------
PROPOSED FIX:
--------------------------
Use this code instead:
$request->header( Referer => "$self->{last_uri}" ) if
$self->{last_uri};
Note that here the $self->{last_uri} is enclosed in quotation marks
which would
effectively stringify the value before passing it in.
--------------------------
AUTHOR:
--------------------------
Eugene Haimov
5/20/2004
email: iiap623616@seic.com