]> bicyclesonthemoon.info Git - ott/post/commitdiff
develop wget
authorb <rowerynaksiezycu@gmail.com>
Wed, 5 Jul 2023 22:53:26 +0000 (22:53 +0000)
committerb <rowerynaksiezycu@gmail.com>
Wed, 5 Jul 2023 22:53:26 +0000 (22:53 +0000)
botm-common
sendpost.1.pl

index f59a33c43337111906246e3c26df2445886255bb..e44d4fc88013f9ad09186ce3cfc73d93829103d2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f59a33c43337111906246e3c26df2445886255bb
+Subproject commit e44d4fc88013f9ad09186ce3cfc73d93829103d2
index 5a5cb106c768cc79839022029fadb23c91181d62..c2a64512b7cb252177498c88d57655913f518890 100644 (file)
@@ -23,7 +23,8 @@ use Encode ('encode', 'decode');
 
 ###PERL_LIB: use lib '/botm/lib/post';
 use botm_common (
-       'read_data_file', 'write_data_file',
+       'read_data_file', 'write_data_file', 'write_postdata_file',
+       'read_header_file',
        'merge_url',
        'make_temp_path',
        'system_encoded'
@@ -272,18 +273,65 @@ sub post_to_mirror {
        my $cookie_path   = make_temp_path(TMP_PATH, 'sendpost.cookie.txt');
        my $postdata_path = make_temp_path(TMP_PATH, 'sendpost.postdata.txt');
        
-       wget($post_url, $tmp_path);
-
+       my %wget_options = (
+               'with_header', 1,
+               'cookie_path', $cookie_path,
+               'postdata_path', $postdata_path
+       );
+       my %post_data = (
+               'uvwxyz', 'eół',
+               'lel', 'lol'
+       );
+       
+       wget($post_url, $tmp_path, \%wget_options, \%post_data);
+       
+       # unlink($tmp_path, $cookie_path, $postdata_path);
        
 }
 
 sub wget {
-       (my $url, my $path, my $postdata) = @_;
+       (my $url, my $path, my $options, my $postdata) = @_;
+       
+       my @arg = (
+               WGET,
+               '-q'
+       );
+       
+       if ($options->{'with_header'}) {
+               push(@arg, '--save-headers');
+       }
+       
+       if ($options->{'cookie_path'} ne '') {
+               if (-f $options->{'cookie_path'}) {
+                       push(@arg, '--load-cookies='.$options->{'cookie_path'});
+               }
+               push(@arg, '--save-cookies='.$options->{'cookie_path'});
+       }
+       else {
+               push(@arg, '--no-cookies');
+       }
+       
+       if ($options->{'postdata_path'} ne '') {
+               if (defined $postdata) {
+                       write_postdata_file(
+                               $options->{'postdata_path'},
+                               ENCODING_FILE, '',
+                               $postdata
+                       );
+                       push(@arg, '--post-file='.$options->{'postdata_path'});
+               }
+       }
+       
+       push(@arg, (
+               $url,
+               '-O', $path
+       ));
+       
        
-       my @arg = (WGET, '-q', $url, '-O', $path);
        system_encoded(WGET, @arg);
        
        
        return 1;
        
 }
+