You could calculate your own timeout time depending on the length of the input after receiving the header like
my $timeout = 120 + int($size/1024)*60;
or something simular. Perhaps you have to play around with the "120" and "60" to get values fitting with your environment.
Other posts pointed out how to set this timeout-time after calculating it.
Comment on Re: how can I timeout a function like "read" when reading from a socket
thanks for the help......its finally running now:)
good idea with the timout calculation....was thinking about different timeouts but thats a much better solution with a basic timeout and an additional time depending on length :)