Skip to content

Commit

Permalink
Merge pull request #46 from CargoSense/timeout-fix
Browse files Browse the repository at this point in the history
Fix HTTP request issues
  • Loading branch information
benwilson512 committed Jul 8, 2015
2 parents c667ea1 + 97916d7 commit 385ffe2
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def deps do
[
ex_aws: "~> 0.4.0",
poison: "~> 1.2.0",
httpoison: "~> 0.6.0"
httpoison: "~> 0.7.0"
]
end
```
Expand Down
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use Mix.Config
config :ex_aws,
http_client: Test.HTTPClient,
http_client: ExAws.Request.HTTPoison,
json_codec: Test.JSONCodec

config :ex_aws, :kinesis,
Expand Down
6 changes: 3 additions & 3 deletions lib/ex_aws/config/defaults.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule ExAws.Config.Defaults do
end
def defaults(:dev) do
[
http_client: HTTPoison,
http_client: ExAws.Request.HTTPoison,
json_codec: Poison,
kinesis: [
scheme: "https://",
Expand Down Expand Up @@ -38,7 +38,7 @@ defmodule ExAws.Config.Defaults do
end
def defaults(:test) do
[
http_client: HTTPoison,
http_client: ExAws.Request.HTTPoison,
json_codec: Poison,
dynamodb: [
scheme: "http://",
Expand All @@ -50,7 +50,7 @@ defmodule ExAws.Config.Defaults do
end
def defaults(:prod) do
[
http_client: HTTPoison,
http_client: ExAws.Request.HTTPoison,
json_codec: Poison,
kinesis: [
scheme: "https://",
Expand Down
37 changes: 37 additions & 0 deletions lib/ex_aws/request/httpoison.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
defmodule ExAws.Request.HTTPoison do
@behaviour ExAws.Request.HttpClient

@moduledoc """
Configuration for HTTPoison
Options can set for HTTPoison with the following config
HTTPoison 0.7.X
```
config :ex_aws, :httpoison_opts,
recv_timeout: 30_000
```
HTTPoison 0.6.X
```
config :ex_aws, :httpoison_opts,
hackney: [recv_timeout: 30_000]
```
The default config handles setting both of the above
"""

@default_timeout 30_000

# The recv_timeout is repeated inside :hackney because in 0.6.X of
# HTTPoison it couldn't be set as an option to httpoison directly.
@default_opts [
recv_timeout: @default_timeout,
hackney: [recv_timeout: @default_timeout]
]

def request(method, url, body, headers) do
opts = Application.get_env(:ex_aws, :httpoison_opts, @default_opts)
HTTPoison.request(method, url, body, headers, opts)
end
end
File renamed without changes.
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule ExAws.Mixfile do
{:earmark, "~> 0.1", only: :dev},
{:ex_doc, "~> 0.7", only: :dev},
{:sweet_xml, "~> 0.2.1", only: [:test]},
{:httpoison, "~> 0.6.0", only: [:test, :dev]},
{:httpoison, "~> 0.7", only: [:test, :dev]},
{:poison, "~> 1.2.0", only: [:test, :dev]},
{:ibrowse, github: "cmullaparthi/ibrowse", tag: "v4.1.1", only: :test},
{:httpotion, "~> 2.0.0", only: :test},
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{"earmark": {:hex, :earmark, "0.1.17"},
"ex_doc": {:hex, :ex_doc, "0.7.3"},
"hackney": {:hex, :hackney, "1.1.0"},
"httpoison": {:hex, :httpoison, "0.6.2"},
"hackney": {:hex, :hackney, "1.2.0"},
"httpoison": {:hex, :httpoison, "0.7.0"},
"httpotion": {:hex, :httpotion, "2.0.0"},
"ibrowse": {:git, "git://github.com/cmullaparthi/ibrowse.git", "d2e369ff42666c3574b8b7ec26f69027895c4d94", [tag: "v4.1.1"]},
"idna": {:hex, :idna, "1.0.2"},
Expand Down
8 changes: 0 additions & 8 deletions test/default_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ end

## Other

defmodule Test.HTTPClient do
@behaviour ExAws.Request.HttpClient

def request(method, url, body, headers) do
HTTPoison.request(method, url, body, headers)
end
end

defmodule Test.JSONCodec do
@behaviour ExAws.JSON.Codec

Expand Down

0 comments on commit 385ffe2

Please sign in to comment.