#endif
#include <stdio.h>
+#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
if (vik_verbose)
curl_easy_setopt ( curl, CURLOPT_VERBOSE, 1 );
curl_easy_setopt ( curl, CURLOPT_NOSIGNAL, 1 ); // Yep, we're a multi-threaded program so don't let signals mess it up!
+ if ( options != NULL && options->user_pass ) {
+ curl_easy_setopt ( curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY );
+ curl_easy_setopt ( curl, CURLOPT_USERPWD, options->user_pass );
+ }
curl_easy_setopt ( curl, CURLOPT_URL, uri );
curl_easy_setopt ( curl, CURLOPT_WRITEDATA, f );
curl_easy_setopt ( curl, CURLOPT_WRITEFUNCTION, curl_write_func);
int ret;
gchar *full = NULL;
- /* Compose the full url */
- full = g_strdup_printf ( "%s://%s%s", (ftp?"ftp":"http"), hostname, uri );
+ if ( strstr ( hostname, "://" ) != NULL )
+ /* Already full url */
+ full = (gchar *) hostname;
+ else if ( strstr ( uri, "://" ) != NULL )
+ /* Already full url */
+ full = (gchar *) uri;
+ else
+ /* Compose the full url */
+ full = g_strdup_printf ( "%s://%s%s", (ftp?"ftp":"http"), hostname, uri );
ret = curl_download_uri ( full, f, options, file_options, handle );
- g_free ( full );
+ /* Free newly allocated memory, but do not free uri */
+ if ( hostname != full && uri != full )
+ g_free ( full );
full = NULL;
return ret;