diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-11-03 21:27:26 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-11-03 21:27:26 +0000 |
| commit | ee1d68bbbfe89b3aa131d912747e5da4a746fdce (patch) | |
| tree | 9536d458a2f75fd80f557f7706c954750d291fd5 /src/lib/internet.cc | |
| parent | e40e1a777ab7b39046e8ff1928354d38bd762db5 (diff) | |
Various improvements in robustness / neatness of certificate download stuff.
Diffstat (limited to 'src/lib/internet.cc')
| -rw-r--r-- | src/lib/internet.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/internet.cc b/src/lib/internet.cc index 7bc818717..2b1e90ca7 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -17,16 +17,17 @@ */ -#include <string> +#include "scoped_temporary.h" +#include "compose.hpp" +#include "safe_stringstream.h" +#include "exceptions.h" +#include <curl/curl.h> +#include <zip.h> #include <boost/function.hpp> #include <boost/optional.hpp> #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> -#include <curl/curl.h> -#include <zip.h> -#include "scoped_temporary.h" -#include "compose.hpp" -#include "safe_stringstream.h" +#include <string> #include "i18n.h" @@ -111,11 +112,11 @@ ftp_ls_data (void* buffer, size_t size, size_t nmemb, void* data) } list<string> -ftp_ls (string url) +ftp_ls (string url, bool pasv) { CURL* curl = curl_easy_init (); if (!curl) { - return list<string> (); + throw NetworkError ("could not set up curl"); } if (url.substr (url.length() - 1, 1) != "/") { @@ -132,9 +133,13 @@ ftp_ls (string url) curl_easy_setopt (curl, CURLOPT_WRITEDATA, &ls_raw); curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ftp_ls_data); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0); + if (!pasv) { + curl_easy_setopt (curl, CURLOPT_FTPPORT, ""); + } CURLcode const r = curl_easy_perform (curl); if (r != CURLE_OK) { - return list<string> (); + curl_easy_cleanup (curl); + throw NetworkError (curl_easy_strerror (r)); } SafeStringStream s (ls_raw); |
