sub recv_req {
my $browser = shift;
my $content_length = 0;
my $req = "";
while (1) {
my $chunk;
$browser->recv($chunk, 10000);
if ($chunk =~ m/Content-Length: (\d*)/) {
$content_length = $1;
print "content_length = $content_length\n";
}
$req .= $chunk;
last if ($chunk =~ "\r\n\r\n");
}
$req =~ /(.*?)\r\n\r\n(.*)/s;
if (length($2) > 0) {
$content_length -= length($2);
print "after -, content_length = $content_length\n";
print "[$2]\n";# I added this line minutes ago to capture $2
}
while ($content_length > 0) {
my $chunk;
$browser->recv($chunk, $content_length);
$req .= $chunk;
$content_length -= length($chunk);
}
return $req;
}
####
print "after -, content_length = $content_length\n";
####
print "[$2]\n";
####
after -, content_length = -2
[node_id=3628&deletemsg_540904478=yup&op=message&message=&message_send=talk&.cgi #this line break here is caused by screen width
fields=deletemsg_540904478
]