How can I verify that I have uploaded the entire file in Perl?

Does file size make sense? I tried to disconnect the connection at boot time, but it looks like size criterion has never been reached.

#!/usr/bin/env perl
use warnings; 
use strict;
use 5.012;
use LWP::Simple;

my $url = 'http://www.kernel.org/pub/linux/kernel/v2.6/next/patch-v2.6.34-rc5-next-20100428.bz2';
my $file = 'next_kernel.bz';
my $file_size = '3462166';

my $response = getstore( $url, $file );
if ( is_success $response ) {
    if ( $file_size == -s $file ) {
        say "OK";
    }
    else {
        say "Not OK";
    }
}
+3
source share
3 answers

If you just want to use the test code, enter the wrong file size and make sure your download is not "OK". If you want to check what happens with an aborted connection, you need a much larger file - downloading in 2342 bytes should take only a fraction of a second.

+2
source

This is strange, I got the same results as you. I have no solution, but I am telling you a little bit about how to crack your problem.

, , , , . bunzip2 , .

LWP:: UserAgent content_file get(). response_data $ua.

:

GET http://www.kernel.org/pub/linux/kernel/v2.6/next/patch-v2.6.34-rc5-next-20100428.bz2 > next_kernel.bz

GET - lwp-request script, LWP, , , .

, .

+1

, , , is_success true, .

0

Source: https://habr.com/ru/post/1743168/


All Articles