summaryrefslogtreecommitdiff
path: root/ext/curl/gstcurlftpsink.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebrn@axis.com>2014-04-16 01:50:16 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-04-26 10:24:24 +0200
commit241c3acad52f5091836f60e4678f910ae28113b5 (patch)
tree01951ddf23cf30b7e1eb5eb0408296dd1226b22e /ext/curl/gstcurlftpsink.c
parentc75c7a9a53e1d2e34ba96600923a294651db7f89 (diff)
downloadgstreamer-plugins-bad-241c3acad52f5091836f60e4678f910ae28113b5.tar.gz
curl*sink: report errors from curl when setting options
https://bugzilla.gnome.org/show_bug.cgi?id=728960
Diffstat (limited to 'ext/curl/gstcurlftpsink.c')
-rw-r--r--ext/curl/gstcurlftpsink.c72
1 files changed, 55 insertions, 17 deletions
diff --git a/ext/curl/gstcurlftpsink.c b/ext/curl/gstcurlftpsink.c
index 114bc97be..64ad0bc88 100644
--- a/ext/curl/gstcurlftpsink.c
+++ b/ext/curl/gstcurlftpsink.c
@@ -178,6 +178,7 @@ set_ftp_dynamic_options_unlocked (GstCurlBaseSink * basesink)
{
gchar *tmp = NULL;
GstCurlFtpSink *sink = GST_CURL_FTP_SINK (basesink);
+ CURLcode res;
if (sink->tmpfile_create) {
gchar *rename_from = NULL;
@@ -213,10 +214,25 @@ set_ftp_dynamic_options_unlocked (GstCurlBaseSink * basesink)
}
tmp = g_strdup_printf ("%s%s", basesink->url, uploadfile_as);
- curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
+
+ res = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
+ if (res != CURLE_OK) {
+ g_free (tmp);
+ basesink->error = g_strdup_printf ("failed to set URL: %s",
+ curl_easy_strerror (res));
+ return FALSE;
+ }
+
sink->headerlist = curl_slist_append (sink->headerlist, rename_from);
sink->headerlist = curl_slist_append (sink->headerlist, rename_to);
- curl_easy_setopt (basesink->curl, CURLOPT_POSTQUOTE, sink->headerlist);
+
+ res = curl_easy_setopt (basesink->curl, CURLOPT_POSTQUOTE, sink->headerlist);
+ if (res != CURLE_OK) {
+ g_free (tmp);
+ basesink->error = g_strdup_printf ("failed to set post quote: %s",
+ curl_easy_strerror (res));
+ return FALSE;
+ }
g_free (rename_from);
g_free (rename_to);
@@ -228,7 +244,13 @@ set_ftp_dynamic_options_unlocked (GstCurlBaseSink * basesink)
}
} else {
tmp = g_strdup_printf ("%s%s", basesink->url, basesink->file_name);
- curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
+ res = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
+ if (res != CURLE_OK) {
+ g_free (tmp);
+ basesink->error = g_strdup_printf ("failed to set URL: %s",
+ curl_easy_strerror (res));
+ return FALSE;
+ }
}
g_free (tmp);
@@ -240,12 +262,18 @@ static gboolean
set_ftp_options_unlocked (GstCurlBaseSink * basesink)
{
GstCurlFtpSink *sink = GST_CURL_FTP_SINK (basesink);
+ CURLcode res;
- curl_easy_setopt (basesink->curl, CURLOPT_UPLOAD, 1L);
+ res = curl_easy_setopt (basesink->curl, CURLOPT_UPLOAD, 1L);
+ if (res != CURLE_OK) {
+ basesink->error = g_strdup_printf ("failed to prepare for upload: %s",
+ curl_easy_strerror (res));
+ return FALSE;
+ }
if (sink->ftp_port_arg != NULL && (strlen (sink->ftp_port_arg) > 0)) {
/* Connect data stream actively. */
- CURLcode res = curl_easy_setopt (basesink->curl, CURLOPT_FTPPORT,
+ res = curl_easy_setopt (basesink->curl, CURLOPT_FTPPORT,
sink->ftp_port_arg);
if (res != CURLE_OK) {
@@ -253,21 +281,31 @@ set_ftp_options_unlocked (GstCurlBaseSink * basesink)
curl_easy_strerror (res));
return FALSE;
}
-
- goto end;
- }
-
- /* Connect data stream passively.
- * libcurl will always attempt to use EPSV before PASV.
- */
- if (!sink->epsv_mode) {
- /* send only plain PASV command */
- curl_easy_setopt (basesink->curl, CURLOPT_FTP_USE_EPSV, 0);
+ } else {
+ /* Connect data stream passively.
+ * libcurl will always attempt to use EPSV before PASV.
+ */
+ if (!sink->epsv_mode) {
+ /* send only plain PASV command */
+ res = curl_easy_setopt (basesink->curl, CURLOPT_FTP_USE_EPSV, 0);
+ if (res != CURLE_OK) {
+ basesink->error =
+ g_strdup_printf ("failed to set extended passive mode: %s",
+ curl_easy_strerror (res));
+ return FALSE;
+ }
+ }
}
-end:
if (sink->create_dirs) {
- curl_easy_setopt (basesink->curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
+ res = curl_easy_setopt (basesink->curl, CURLOPT_FTP_CREATE_MISSING_DIRS,
+ 1L);
+ if (res != CURLE_OK) {
+ basesink->error =
+ g_strdup_printf ("failed to set create missing dirs: %s",
+ curl_easy_strerror (res));
+ return FALSE;
+ }
}
return TRUE;