[LONG] Re: Illegal content in request
acassin@cs.mu.oz.au
Mon, 10 Nov 1997 11:55:59 +1100 (EST)
[apologies for such a long-winded and cryptic bug report :) ]
On 7 Nov , Gisle Aas wrote:
>> I am having _some_ requests (sorry, I cant publish the code)
>> fail due to an 'Illegal content in request' and debugging in
>> LWP::Protocol::http::request() shows ref($contRef) eq 'LVALUE'
>
> Hard to tell without some code. I have no idea what to do to get a
> reference to an LVALUE in perl. I wish I did.
You and me both. I sure wish I knew what was going on. The program in
question obtains a set of urls (from ~/.netscape/bookmarks.html) and
visits them in turn checking to see if they have bytewise-changed
(using If-Modified-Since when possible). The following traces show
$content and $contRef in LWP::Protocol::http::request use'ing
Devel::Peek
Early on during the run, the requests proceed just fine:
--- HTTP::Request=HASH(0x140656cd8) ---
GET http://titan.lib.unimelb.edu.au/collections/mathematics/MSLib.html
Pragma: no-cache
Accept: text/html, image/*, www/unknown
Host: www.lib.unimelb.edu.au
If-Modified-Since: Thu, 30 Oct 1997 17:04:09 GMT
-----------------------------------
content is:
SV = PVIV(0x140683808)
REFCNT = 2
FLAGS = (PADBUSY,PADMY,POK,pPOK)
IV = 0
PV = 0x140692da8 ""
CUR = 0
LEN = 1
contRef is:
SV = RV(0x1406569b8)
REFCNT = 1
FLAGS = (PADBUSY,PADMY,ROK)
RV = 0x14066aea8
SV = PVIV(0x140683808)
REFCNT = 2
FLAGS = (PADBUSY,PADMY,POK,pPOK)
IV = 0
PV = 0x140692da8 ""
CUR = 0
LEN = 1
LWP::IO::write: Write 277 bytes: 'GET http://titan.lib.unimelb.edu.au/collections
/mathematics/MSLib.html HTTP/1.0^M
Pragma: no-cache^M
Accept: text/html, image/*, www/unknown^M
From: acassin@cs.mu.oz.au^M
Host: titan.lib.unimelb.edu.au^M
If-Modified-Since: Thu, 30 Oct 1997 17:04:09 GMT^M
User-Agent: HotMarks/1.0^M
^M
'
LWP::IO::read: HTTP/1.0 304 Not modified
Date: Sun, 09 Nov 1997 23:47:50 GMT
Server: NCSA/1.5
but then, about halfway through the bookmarks this happens:
--- HTTP::Request=HASH(0x140707818) ---
GET http://www.troopers.demon.co.uk/text.htm
Accept: text/html, image/*, www/unknown
Host: www.troopers.demon.co.uk
-----------------------------------
content is:
SV = PVLV(0x140702908)
REFCNT = 2
FLAGS = (PADBUSY,PADMY,POK,pPOK)
IV = 0
NV = 0
PV = 0x1406ddea8 ""
CUR = 0
LEN = 1
TYPE =
TARGOFF = 0
TARGLEN = 0
TARG = 0x0
SV = 0
contRef is:
SV = RV(0x1406569b8)
REFCNT = 1
FLAGS = (PADBUSY,PADMY,ROK)
RV = 0x14066aea8
SV = PVLV(0x140702908)
REFCNT = 2
FLAGS = (PADBUSY,PADMY,POK,pPOK)
IV = 0
NV = 0
PV = 0x1406ddea8 ""
CUR = 0
LEN = 1
TYPE =
TARGOFF = 0
TARGLEN = 0
TARG = 0x0
SV = 0
The debugging code in LWP::Protocol::http::request() looks like this:
# If we're sending content we *have* to specify a content length
# otherwise the server won't know a messagebody is coming.
my $content = $request->content;
# All this mess because we want to support content as both scalar,
# ref to scalar and ref to code.
my $contRef;
if (defined $content){
$contRef = ref($content) ? $content : \$content;
print STDERR "content is:\n"; Dump($content);
print STDERR "contRef is:\n"; Dump($contRef);
if (ref($contRef) eq 'SCALAR') {
$request->header('Content-Length', length $$contRef)
if length $$contRef;
} elsif (ref($contRef) eq 'CODE') {
Carp::croak('No Content-Length header for request with content')
unless $request->header('Content-Length');
} else {
Carp::croak("Illegal content in request ($content)");
}
}
Any ideas?
Andrew Cassin
acassin@cs.mu.oz.au