add tests for exec and getConnection methods in HttpRequest class
[arvados.git] / sdk / R / R / HttpRequest.R
index bc6b4d406d1f801acb7328a5d9263b44a473b2a7..d1100a2e5fe99ee5971d0c152a7103fe2b2b3391 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
 source("./R/util.R")
 
 HttpRequest <- R6::R6Class(
@@ -26,7 +30,7 @@ HttpRequest <- R6::R6Class(
 
             config <- httr::add_headers(unlist(headers))
             if(toString(Sys.getenv("ARVADOS_API_HOST_INSECURE") == "TRUE"))
-               config$options = list(ssl_verifypeer = FALSE)
+               config$options = list(ssl_verifypeer = 0L)
 
             # times = 1 regular call + numberOfRetries
             response <- httr::RETRY(verb, url = url, body = body,
@@ -54,6 +58,17 @@ HttpRequest <- R6::R6Class(
             }
 
             return("")
+        },
+
+        getConnection = function(url, headers, openMode) 
+        {
+            h <- curl::new_handle()
+            curl::handle_setheaders(h, .list = headers)
+
+            if(toString(Sys.getenv("ARVADOS_API_HOST_INSECURE") == "TRUE"))
+               curl::handle_setopt(h, ssl_verifypeer = 0L)
+
+            conn <- curl::curl(url = url, open = openMode, handle = h)
         }
     ),