From b86a7c8ed256a4e62799d284982cc8b68a573381 Mon Sep 17 00:00:00 2001 From: Michael Alekseev Date: Mon, 5 Oct 2015 21:10:37 +0600 Subject: moved from httpotion to httpoison --- README.md | 3 +-- lib/recaptcha.ex | 9 +++++---- mix.exs | 7 +++---- mix.lock | 10 +++++++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f2a8bf4..8864e16 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,7 @@ A simple Elixir package for implementing [reCAPTCHA] in [Phoenix] applications. ```elixir defp deps do [ - {:recaptcha, "~> 1.0.0"}, - {:ibrowse, github: "cmullaparthi/ibrowse", tag: "v4.1.2"} + {:recaptcha, "~> 1.1.0"}, ] end ``` diff --git a/lib/recaptcha.ex b/lib/recaptcha.ex index 7ff1eb8..e0656c3 100644 --- a/lib/recaptcha.ex +++ b/lib/recaptcha.ex @@ -49,13 +49,14 @@ defmodule Recaptcha do defp api_response(remote_ip, response, options) do private_key = options[:private_key] || config.private_key - timeout = options[:timeout] || 3000 + timeout = options[:timeout] || 5000 body_content = URI.encode_query(%{"remoteip" => to_string(remote_ip), "response" => response, "secret" => private_key}) - headers = ["Content-type": "application/x-www-form-urlencoded"] - options = [body: body_content, headers: headers, timeout: timeout] - HTTPotion.post(config.verify_url, options).body |> Poison.decode! + headers = [{"Content-type", "application/x-www-form-urlencoded"}, {"Accept", "application/json"}] + + HTTPoison.post!(config.verify_url, body_content, headers, timeout: timeout).body + |> Poison.decode! end defp config do diff --git a/mix.exs b/mix.exs index b7a0ae2..7dcc1a0 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule Recaptcha.Mixfile do def project do [app: :recaptcha, - version: "1.0.2", + version: "1.1.0", elixir: "~> 1.0", description: description, deps: deps, @@ -11,7 +11,7 @@ defmodule Recaptcha.Mixfile do end def application do - [applications: [:logger, :httpotion]] + [applications: [:logger, :httpoison]] end defp description do @@ -22,8 +22,7 @@ defmodule Recaptcha.Mixfile do defp deps do [ - {:ibrowse, github: "cmullaparthi/ibrowse", tag: "v4.1.2"}, - {:httpotion, "~> 2.1.0"}, + {:httpoison, "0.7.2"}, {:poison, "~> 1.5"} ] end diff --git a/mix.lock b/mix.lock index 1109ea8..eac4b1b 100644 --- a/mix.lock +++ b/mix.lock @@ -1,3 +1,7 @@ -%{"httpotion": {:hex, :httpotion, "2.1.0"}, - "ibrowse": {:git, "git://github.com/cmullaparthi/ibrowse.git", "ea3305d21f37eced4fac290f64b068e56df7de80", [tag: "v4.1.2"]}, - "poison": {:hex, :poison, "1.5.0"}} +%{"hackney": {:hex, :hackney, "1.3.2"}, + "httpoison": {:hex, :httpoison, "0.7.4"}, + "httpotion": {:hex, :httpotion, "2.1.0"}, + "ibrowse": {:git, "https://github.com/cmullaparthi/ibrowse.git", "ea3305d21f37eced4fac290f64b068e56df7de80", [tag: "v4.1.2"]}, + "idna": {:hex, :idna, "1.0.2"}, + "poison": {:hex, :poison, "1.5.0"}, + "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"}} -- cgit v1.2.1