aboutsummaryrefslogtreecommitdiffstats
path: root/grpmi/curl_download
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2002-08-30 18:15:36 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2002-08-30 18:15:36 +0000
commit825a6a0d7b41e624c01d0236ec73d31296c352c6 (patch)
tree9932bf3bb6ca7b5d10ca80aca7e4d122a402d5bd /grpmi/curl_download
parent0e08c3052db01f30ac90f56c6d57a8ec3b01e29b (diff)
downloadrpmdrake-825a6a0d7b41e624c01d0236ec73d31296c352c6.tar
rpmdrake-825a6a0d7b41e624c01d0236ec73d31296c352c6.tar.gz
rpmdrake-825a6a0d7b41e624c01d0236ec73d31296c352c6.tar.bz2
rpmdrake-825a6a0d7b41e624c01d0236ec73d31296c352c6.tar.xz
rpmdrake-825a6a0d7b41e624c01d0236ec73d31296c352c6.zip
handle /etc/urpmi/proxy.cfg proxies, have a proxy dialog config in
edit-urpm-sources
Diffstat (limited to 'grpmi/curl_download')
-rw-r--r--grpmi/curl_download/curl_download.pm27
-rw-r--r--grpmi/curl_download/curl_download.xs11
2 files changed, 33 insertions, 5 deletions
diff --git a/grpmi/curl_download/curl_download.pm b/grpmi/curl_download/curl_download.pm
index 329a05c2..7c6ec472 100644
--- a/grpmi/curl_download/curl_download.pm
+++ b/grpmi/curl_download/curl_download.pm
@@ -1,14 +1,39 @@
package curl_download;
use strict;
-use vars qw($VERSION @ISA);
+use vars qw($VERSION @ISA @EXPORT);
+use MDK::Common;
require DynaLoader;
@ISA = qw(DynaLoader);
+@EXPORT = qw(download readproxy writeproxy);
$VERSION = '1.0';
bootstrap curl_download $VERSION;
+sub readproxy {
+ my ($proxy, $proxy_user);
+ foreach (cat_('/etc/urpmi/proxy.cfg')) {
+ /^http_proxy\s*=\s*(.*)$/ and $proxy = $1;
+ /^ftp_proxy\s*=\s*(.*)$/ and $proxy = $1;
+ /^proxy_user\s*=\s*(.*)$/ and $proxy_user = $1;
+ }
+ ($proxy, $proxy_user);
+}
+
+sub writeproxy {
+ my ($proxy, $proxy_user) = @_;
+ output("/etc/urpmi/proxy.cfg",
+ if_($proxy, "http_proxy=$proxy\n"),
+ if_($proxy_user, "proxy_user=$proxy_user\n"));
+}
+
+sub download {
+ my ($url, $location, $downloadprogress_callback) = @_;
+
+ download_real($url, $location, $downloadprogress_callback, readproxy());
+}
+
1;
diff --git a/grpmi/curl_download/curl_download.xs b/grpmi/curl_download/curl_download.xs
index ab200d6f..2297555d 100644
--- a/grpmi/curl_download/curl_download.xs
+++ b/grpmi/curl_download/curl_download.xs
@@ -71,7 +71,7 @@ int my_progress_func(void *ptr, double td, double dd, double tu, double du)
return 0;
}
-char * download_url_real(char * url, char * location, char * proxy)
+char * download_url_real(char * url, char * location, char * proxy, char * proxy_user)
{
CURL *curl;
CURLcode rescurl = CURL_LAST;
@@ -108,6 +108,8 @@ char * download_url_real(char * url, char * location, char * proxy)
if (proxy && strcmp(proxy, ""))
curl_easy_setopt(curl, CURLOPT_PROXY, proxy);
+ if (proxy_user && strcmp(proxy_user, ""))
+ curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, proxy_user);
rescurl = curl_easy_perform(curl);
@@ -269,14 +271,15 @@ MODULE = curl_download PACKAGE = curl_download
PROTOTYPES : DISABLE
char *
-download(url, location, proxy, downloadprogress_callback)
+download_real(url, location, downloadprogress_callback, proxy, proxy_user)
char * url
char * location
- char * proxy
SV * downloadprogress_callback
+ char * proxy
+ char * proxy_user
CODE:
downloadprogress_callback_sv = downloadprogress_callback;
- RETVAL = download_url_real(url, location, proxy);
+ RETVAL = download_url_real(url, location, proxy, proxy_user);
OUTPUT:
RETVAL