aboutsummaryrefslogtreecommitdiffstats
path: root/grpmi/curl_download/curl_download.pm
blob: ee8875148e97f043be1ce7ad7b277300be37765e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package curl_download;

use strict;
use MDK::Common;
use urpm::download;

require DynaLoader;

our @ISA = qw(DynaLoader);
our @EXPORT = qw(download readproxy writeproxy);
our $VERSION = '1.1';

bootstrap curl_download $VERSION;

sub readproxy (;$) {
    my $proxy = get_proxy($_[0]);
    ($proxy->{http_proxy} || $proxy->{ftp_proxy} || '',
	defined $proxy->{user} ? "$proxy->{user}:$proxy->{pwd}" : '');
}

sub writeproxy {
    my ($proxy, $proxy_user, $o_media_name) = @_;
    my ($user, $pwd) = split /:/, $proxy_user;
    set_proxy_config(user => $user, $o_media_name);
    set_proxy_config(pwd => $pwd, $o_media_name);
    set_proxy_config(http_proxy => $proxy, $o_media_name);
    dump_proxy_config();
}

sub download {
    my ($url, $location, $downloadprogress_callback) = @_;

    download_real($url, $location, $downloadprogress_callback, readproxy());
}

1;