* (*excluding* null terminator) */
#define S3_MAX_KEY_LENGTH 1024
-#if defined(LIBCURL_FEATURE_SSL) && defined(LIBCURL_PROTOCOL_HTTPS)
-# define S3_URL "https://s3.amazonaws.com"
-#else
-# define S3_URL "http://s3.amazonaws.com"
-#endif
-
#define AMAZON_SECURITY_HEADER "x-amz-security-token"
/* parameters for exponential backoff in the face of retriable errors */
static const char *
s3_error_name_from_code(s3_error_code_t s3_error_code);
+/* Does this install of curl support SSL?
+ *
+ * @returns: boolean
+ */
+static gboolean
+s3_curl_supports_ssl(void);
+
/*
* result handling */
}
/* }}} */
+/* {{{ s3_curl_supports_ssl */
+static gboolean
+s3_curl_supports_ssl(void)
+{
+ static int supported = -1;
+
+ if (supported == -1) {
+#if defined(CURL_VERSION_SSL)
+ curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
+ if (info->features & CURL_VERSION_SSL)
+ supported = 1;
+ else
+ supported = 0;
+#else
+ supported = 0;
+#endif
+ }
+
+ return supported;
+}
+/* }}} */
+
/* {{{ lookup_result */
static s3_result_t
lookup_result(const result_handling_t *result_handling,
guint preallocate_response_size,
const result_handling_t *result_handling)
{
+ const char *baseurl;
char *url = NULL;
s3_result_t result = S3_RESULT_FAIL; /* assume the worst.. */
CURLcode curl_code = CURLE_OK;
s3_reset(hdl);
- url = g_strconcat(S3_URL, uri, NULL);
+ baseurl = s3_curl_supports_ssl()? "https://s3.amazonaws.com":"http://s3.amazonaws.com";
+ url = g_strconcat(baseurl, uri, NULL);
if (!url) goto cleanup;
if (preallocate_response_size) {