From c231eabe6e31f74a301a98730f67973ad6addbc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cam=20Sa=C3=BCl?= <cammsaul@gmail.com>
Date: Tue, 23 Feb 2016 17:14:42 -0800
Subject: [PATCH] Don't need 2 different HTTP libs :scream_cat:

---
 project.clj                         | 11 +++++------
 src/metabase/integrations/slack.clj | 19 +++++++++----------
 test/metabase/api/notify_test.clj   |  2 +-
 test/metabase/http_client.clj       | 12 ++++++------
 4 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/project.clj b/project.clj
index 0e44e795654..d9813917ee2 100644
--- a/project.clj
+++ b/project.clj
@@ -20,11 +20,10 @@
                  [org.clojure/tools.namespace "0.2.10"]
                  [amalloy/ring-gzip-middleware "0.1.3"]               ; Ring middleware to GZIP responses if client can handle it
                  [cheshire "5.5.0"]                                   ; fast JSON encoding (used by Ring JSON middleware)
-                 [clj-http "0.3.0"
+                 [clj-http "2.1.0"                                    ; HTTP client
                   :exclusions [commons-codec
                                commons-io
                                slingshot]]
-                 [clj-http-lite "0.3.0"]                              ; HTTP client; lightweight version of clj-http that uses HttpURLConnection instead of Apache
                  [clj-time "0.11.0"]                                  ; library for dealing with date/time
                  [clojurewerkz/quartzite "2.0.0"]                     ; scheduling library
                  [colorize "0.1.1" :exclusions [org.clojure/clojure]] ; string output with ANSI color codes (for logging)
@@ -35,7 +34,7 @@
                                ring/ring-core]]
                  [com.draines/postal "1.11.4"]                        ; SMTP library
                  [com.google.apis/google-api-services-bigquery        ; Google BigQuery Java Client Library
-                  "v2-rev262-1.21.0"]
+                  "v2-rev270-1.21.0"]
                  [com.h2database/h2 "1.4.191"]                        ; embedded SQL database
                  [com.mattbertolini/liquibase-slf4j "2.0.0"]          ; Java Migrations lib
                  [com.novemberain/monger "3.0.2"]                     ; MongoDB Driver
@@ -48,7 +47,7 @@
                                javax.jms/jms
                                com.sun.jdmk/jmxtools
                                com.sun.jmx/jmxri]]
-                 [medley "0.7.1"]                                     ; lightweight lib of useful functions
+                 [medley "0.7.2"]                                     ; lightweight lib of useful functions
                  [mysql/mysql-connector-java "5.1.38"]                ; MySQL JDBC driver
                  [net.sf.cssbox/cssbox "4.10"
                   :exclusions [org.slf4j/slf4j-api]]
@@ -56,7 +55,7 @@
                  [org.xhtmlrenderer/flying-saucer-core "9.0.8"]
                  [org.liquibase/liquibase-core "3.4.2"]               ; migration management (Java lib)
                  [org.slf4j/slf4j-log4j12 "1.7.16"]
-                 [org.yaml/snakeyaml "1.16"]                          ; YAML parser (required by liquibase)
+                 [org.yaml/snakeyaml "1.17"]                          ; YAML parser (required by liquibase)
                  [org.xerial/sqlite-jdbc "3.8.11.2"]                  ; SQLite driver
                  [postgresql "9.3-1102.jdbc41"]                       ; Postgres driver
                  [prismatic/schema "1.0.5"]                           ; Data schema declaration and validation library
@@ -87,7 +86,7 @@
                               :exclusions [org.clojure/clojure]]      ; Linting
                              [lein-ancient "0.6.8"                    ; Check project for outdated dependencies + plugins w/ 'lein ancient'
                               :exclusions [org.clojure/clojure]]
-                             [lein-bikeshed "0.2.0"]                  ; Linting
+                             [lein-bikeshed "0.3.0"]                  ; Linting
                              [lein-expectations "0.0.8"]              ; run unit tests with 'lein expectations'
                              [lein-instant-cheatsheet "2.1.5"         ; use awesome instant cheatsheet created by yours truly w/ 'lein instant-cheatsheet'
                               :exclusions [org.clojure/clojure
diff --git a/src/metabase/integrations/slack.clj b/src/metabase/integrations/slack.clj
index 5ae2de13e56..f06230b7bd6 100644
--- a/src/metabase/integrations/slack.clj
+++ b/src/metabase/integrations/slack.clj
@@ -1,6 +1,5 @@
 (ns metabase.integrations.slack
   (:require [cheshire.core :as cheshire]
-            [clj-http.lite.client :as client]
             [clj-http.client :as http]
             [clojure.tools.logging :as log]
             [metabase.models.setting :refer [defsetting]]))
@@ -22,15 +21,15 @@
 (defn slack-api-get
   "Generic function which calls a given method on the Slack api via HTTP GET."
   ([token method]
-    (slack-api-get token method {}))
+   (slack-api-get token method {}))
   ([token method params]
-    {:pre [(string? method)
-           (map? params)]}
+   {:pre [(string? method)
+          (map? params)]}
    (when token
      (try
-       (client/get (str slack-api-baseurl "/" method) {:query-params   (merge params {:token token})
-                                                       :conn-timeout   1000
-                                                       :socket-timeout 1000})
+       (http/get (str slack-api-baseurl "/" method) {:query-params   (merge params {:token token})
+                                                     :conn-timeout   1000
+                                                     :socket-timeout 1000})
        (catch Throwable t
          (log/warn "Error making Slack API call:" (.getMessage t)))))))
 
@@ -43,9 +42,9 @@
           (map? params)]}
    (when token
      (try
-       (client/post (str slack-api-baseurl "/" method) {:form-params   (merge params {:token token})
-                                                        :conn-timeout   1000
-                                                        :socket-timeout 1000})
+       (http/post (str slack-api-baseurl "/" method) {:form-params   (merge params {:token token})
+                                                      :conn-timeout   1000
+                                                      :socket-timeout 1000})
        (catch Throwable t
          (log/warn "Error making Slack API call:" (.getMessage t)))))))
 
diff --git a/test/metabase/api/notify_test.clj b/test/metabase/api/notify_test.clj
index 044c72e3d64..8acfa8a45aa 100644
--- a/test/metabase/api/notify_test.clj
+++ b/test/metabase/api/notify_test.clj
@@ -1,5 +1,5 @@
 (ns metabase.api.notify-test
-  (:require [clj-http.lite.client :as client]
+  (:require [clj-http.client :as client]
             [expectations :refer :all]
             (metabase [http-client :as http]
                       [middleware :as middleware])))
diff --git a/test/metabase/http_client.clj b/test/metabase/http_client.clj
index 16825f9b8e7..39f96d22ac2 100644
--- a/test/metabase/http_client.clj
+++ b/test/metabase/http_client.clj
@@ -1,8 +1,8 @@
 (ns metabase.http-client
   "HTTP client for making API calls against the Metabase API. For test/REPL purposes."
   (:require [clojure.tools.logging :as log]
-            [cheshire.core :as cheshire]
-            [clj-http.lite.client :as client]
+            [cheshire.core :as json]
+            [clj-http.client :as client]
             [metabase.config :as config]
             [metabase.util :as u]))
 
@@ -67,7 +67,7 @@
                                                                                   credentials))}}
                       (seq http-body) (assoc
                                        :content-type :json
-                                       :body         (cheshire/generate-string http-body)))
+                                       :body         (json/generate-string http-body)))
         request-fn  (case method
                       :get    client/get
                       :post   client/post
@@ -80,14 +80,14 @@
         {:keys [status body]} (try (request-fn url request-map)
                                    (catch clojure.lang.ExceptionInfo e
                                      (log/debug method-name url)
-                                     (:object (.getData ^clojure.lang.ExceptionInfo e))))]
+                                     (:object (ex-data e))))]
 
     ;; -check the status code if EXPECTED-STATUS was passed
     (log/debug method-name url status)
     (when expected-status
       (when-not (= status expected-status)
         (let [message (format "%s %s expected a status code of %d, got %d." method-name url expected-status status)
-              body    (try (-> (cheshire/parse-string body)
+              body    (try (-> (json/parse-string body)
                                clojure.walk/keywordize-keys)
                            (catch Exception _ body))]
           (log/error (u/pprint-to-str 'red body))
@@ -95,7 +95,7 @@
 
     ;; Deserialize the JSON response or return as-is if that fails
     (try (-> body
-             cheshire/parse-string
+             json/parse-string
              clojure.walk/keywordize-keys
              auto-deserialize-dates)
          (catch Exception _
-- 
GitLab