Slow POST requests (again)
Ashley Baumann (ashleyb@sco.com)
Tue, 13 Apr 1999 10:06:09 +0100
Is there a way to return from the following code at the
end of the request subroutine as soon as we see a </BODY>
or </HTML> in the response page? My script currently waits
for 30 seconds after the response has been sent for the server
to close the connection.
sub request
{
.....
$response = $self->collect($arg, $response, sub {
if ($usebuf) {
$usebuf = 0;
return \$buf;
}
die "read timeout" if $timeout && !$sel->can_read($timeout);
my $n = $socket->sysread($buf, $size);
die $! unless defined($n);
#LWP::Debug::conns($buf);
return \$buf;
} );
$socket->close;
$response;
}
Thanks
Ashleyb
------- Forwarded Message
To: libwww-perl@ics.uci.edu
Subject: POST Requests wait for FIN to be sent.
Date: Thu, 25 Mar 1999 18:35:53 +0000
From: Ashley Baumann <ashleyb@sco.com>
Can sombody help me please?
The following program:
========================================================
#!/bin/perl
use URI::URL;
use LWP::UserAgent;
use LWP::Simple;
$ua = new LWP::UserAgent;
$ua->agent("$0/0.1");
my $req = new HTTP::Request 'POST', 'http://server:8080/form.htm';
$req->content_type('application/x-www-form-urlencoded');
$req->content('username=xxxxx&password=xxxxx');
$res = $ua->request($req);
exit 0;
===================================================================
takes a vey long time to complete as the web server on 'server' does
not send a FIN for 30 seconds after it has finished sending the
web page (see tcpdump output below). The request sits in select until
it sees the FIN.
18:26:53.137115 client.1236 > server.8080: P 480:855(375) ack 1968 win 17520
(DF)
18:26:53.137604 client.1236 > server.8080: FP 855:959(104) ack 1968 win 17520
(DF)
18:26:53.137885 client.1237 > server.8080: S 2751910167:2751910167(0) win
16384 <mss 1460> (DF)
18:26:53.138168 server.8080 > client.1236: R 224210747:224210747(0) win 8760
(DF)
18:26:53.138329 server.8080 > client.1236: R 224210747:224210747(0) win 0 (DF)
18:26:53.138655 server.8080 > client.1237: S 281236269:281236269(0) ack
2751910168 win 8760 <mss 1460> (DF)
18:26:53.138696 client.1237 > server.8080: . ack 1 win 17520 (DF)
18:26:53.140300 client.1237 > server.8080: P 1:376(375) ack 1 win 17520 (DF)
18:26:53.187809 server.8080 > client.1237: . ack 376 win 8760 (DF)
18:26:53.187846 client.1237 > server.8080: P 376:480(104) ack 1 win 17520 (DF)
18:26:53.203321 server.8080 > client.1237: P 1:1461(1460) ack 480 win 8760 (DF)
18:26:53.251006 client.1237 > server.8080: . ack 1461 win 16320 (DF)
18:26:53.252130 server.8080 > client.1237: P 1461:1967(506) ack 480 win 8760
(DF)
18:26:53.450980 client.1237 > server.8080: . ack 1967 win 17520 (DF)
18:27:23.203518 server.8080 > client.1237: F 1967:1967(0) ack 480 win 8760 (DF)
18:27:23.203562 client.1237 > server.8080: . ack 1968 win 17520 (DF)
client is a freeBSD3.1 box with 5.005_02 and LWP 5.22.
Is there anything I can do to make the request finish sooner?
Thanks
Ashleyb
--
===============================================================
Ashley Baumann The Santa Cruz Operation Limited
Software Engineer Registered in England No 2063779
Croxley Business Park, Hatters Lane
Watford WD1 8YN, England
Tel: +44 (0)1923 813519 Fax: +44 (0)1923 813804