From 6b7acea494c17fb4347341b6d8c27d2ea9630d9f Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 11 May 2015 12:53:39 -0700 Subject: [PATCH] Add curl version check --- http.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/http.c b/http.c index 095799e..bae6f4d 100644 --- a/http.c +++ b/http.c @@ -430,6 +430,21 @@ Datum http_request(PG_FUNCTION_ARGS) /* Output */ HeapTuple tuple_out; + + /* Version check */ + curl_version_info_data *version_info = curl_version_info(CURLVERSION_NOW); + elog(DEBUG2, "pgsql-http: curl version %s", version_info->version); + elog(DEBUG2, "pgsql-http: curl version number 0x%x", version_info->version_num); + elog(DEBUG2, "pgsql-http: ssl version %s", version_info->ssl_version); + + /* 0x071400 == 7.20.0, each hex digit is for one version level (0xMMmmpp) */ + if ( version_info->version_num < 0x071400 ) + { + elog(ERROR, "pgsql-http requires Curl version 0.7.20 or higher"); + PG_RETURN_NULL(); + } + + /* We cannot handle a null request */ if ( ! PG_ARGISNULL(0) ) rec = PG_GETARG_HEAPTUPLEHEADER(0);