   end
 
   @doc "Download a file to the filesystem."
-  def download_file(url, path, progress_callback \\ nil, payload \\ "", headers \\ [], stream_fun \\ nil)
+  def download_file(url,
+                    path,
+                    progress_callback \\ nil,
+                    payload \\ "",
+                    headers \\ [],
+                    stream_fun \\ nil)
 
-  def download_file(url, path, progress_callback, payload, headers, stream_fun) do
-    GenServer.call(__MODULE__, {:download_file, {url, path, progress_callback, payload, headers, stream_fun}}, :infinity)
+  def download_file(url, path, progress_callback, payload, hddrs, stream_fun) do
+    opts = {url, path, progress_callback, payload, hddrs, stream_fun}
+    call = {:download_file, opts}
+    GenServer.call(__MODULE__, call, :infinity)
   end
 
   @doc "Upload a file to FB storage."

  * opts     - Keyword opts to be passed to adapter (hackney/httpoison)
    * `file` - option to  be passed if the output should be saved to a file.
  """
  @spec request(method, url, body, headers, opts) :: {:ok, Response.t} | {:error, term}
  def request(method, url, body \\ "", headers \\ [], opts \\ [])

  def request(method, url, body, headers, opts) do
    GenServer.call(__MODULE__, {:request, method, url, body, headers, opts}, :infinity)
  end

  @doc "Same as `request/5` but raises."

  use GenServer
  alias Farmbot.HTTP.{Adapter, Error, Response}

  @adapter Application.get_env(:farmbot, :behaviour)[:http_adapter]
  @adapter || raise("No http adapter.")

  @typep method :: Adapter.method
  @typep url :: Adapter.url
