Skip to content

Commit 596fa03

Browse files
committed
Fix CI
1 parent 0b476f8 commit 596fa03

5 files changed

Lines changed: 56 additions & 57 deletions

File tree

.github/workflows/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ jobs:
3131
fail-fast: false
3232
matrix:
3333
include:
34-
- otp: 23.0
35-
elixir: 1.11.2
3634
- otp: 25.1
3735
elixir: 1.14.1
3836
coverage: true

config/config.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use Mix.Config
1+
import Config
22

3-
if Mix.env() == :test do
3+
if config_env() == :test do
44
config :httparrot,
5-
http_port: 8080,
6-
ssl: true,
7-
https_port: 8433
5+
https_port: 8433,
6+
http_port: 4002,
7+
ssl: true
88
end

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ defmodule HTTPoison.Mixfile do
4545
{:mimic, "~> 0.1", only: :test},
4646
{:jason, "~> 1.2", only: :test},
4747
{:httparrot, "~> 1.2", only: :test},
48+
{:cowboy, "~> 2.8", only: :test, override: true},
4849
{:earmark, "~> 1.0", only: :dev},
4950
{:ex_doc, "~> 0.18", only: :dev},
5051
{:dialyxir, "~> 1.0.0-rc.3", only: [:dev, :test], runtime: false}

mix.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
%{
22
"certifi": {:hex, :certifi, "2.5.3", "70bdd7e7188c804f3a30ee0e7c99655bc35d8ac41c23e12325f36ab449b70651", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "ed516acb3929b101208a9d700062d520f3953da3b6b918d866106ffa980e1c10"},
33
"con_cache": {:hex, :con_cache, "0.14.0", "863acb90fa08017be3129074993af944cf7a4b6c3ee7c06c5cd0ed6b94fbc223", [:mix], [], "hexpm", "50887a8949377d0b707a3c6653b7610de06074751b52d0f267f52135f391aece"},
4-
"cowboy": {:hex, :cowboy, "2.8.0", "f3dc62e35797ecd9ac1b50db74611193c29815401e53bac9a5c0577bd7bc667d", [:rebar3], [{:cowlib, "~> 2.9.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "4643e4fba74ac96d4d152c75803de6fad0b3fa5df354c71afdd6cbeeb15fac8a"},
5-
"cowlib": {:hex, :cowlib, "2.9.1", "61a6c7c50cf07fdd24b2f45b89500bb93b6686579b069a89f88cb211e1125c78", [:rebar3], [], "hexpm", "e4175dc240a70d996156160891e1c62238ede1729e45740bdd38064dad476170"},
4+
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
5+
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
66
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
77
"earmark": {:hex, :earmark, "1.4.18", "618c4ff1563450d1832b7fb41dc6755e470f91a6fd4c70f350a58b14f64a7db8", [:mix], [{:earmark_parser, ">= 1.4.17", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "57ac3b6da3958ed09c669a9b159e86377fcccda56bacde8a209fa4dcdef52560"},
88
"earmark_parser": {:hex, :earmark_parser, "1.4.17", "6f3c7e94170377ba45241d394389e800fb15adc5de51d0a3cd52ae766aafd63f", [:mix], [], "hexpm", "f93ac89c9feca61c165b264b5837bf82344d13bebc634cd575cb711e2e342023"},
@@ -22,7 +22,7 @@
2222
"mimic": {:hex, :mimic, "0.3.0", "584dfd5ac2ce3347f56b0de3b7906554e2f6020007efed37e721b968f27ebbc0", [:mix], [], "hexpm", "6e817cbd79bca8c70b90b1e3268fb54bbd0c89387e2143236f0233bf935cc5a1"},
2323
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
2424
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"},
25-
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
25+
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
2626
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
2727
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
2828
}

test/httpoison_test.exs

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ defmodule HTTPoisonTest do
55
alias HTTPoison.Request
66

77
test "get" do
8-
assert_response(HTTPoison.get("localhost:8080/deny"), fn response ->
8+
assert_response(HTTPoison.get("localhost:4002/deny"), fn response ->
99
assert :erlang.size(response.body) == 197
1010
end)
1111
end
1212

1313
test "get with params" do
14-
resp = HTTPoison.get("localhost:8080/get", [], params: %{foo: "bar", baz: "bong"})
14+
resp = HTTPoison.get("localhost:4002/get", [], params: %{foo: "bar", baz: "bong"})
1515

1616
assert_response(resp, fn response ->
1717
args = Jason.decode!(response.body)["args"]
@@ -20,14 +20,14 @@ defmodule HTTPoisonTest do
2020
assert args |> Map.keys() |> length == 2
2121

2222
assert Request.to_curl(response.request) ==
23-
{:ok, "curl -X GET http://localhost:8080/get?baz=bong&foo=bar"}
23+
{:ok, "curl -X GET http://localhost:4002/get?baz=bong&foo=bar"}
2424
end)
2525
end
2626

2727
test "get with params in url and options" do
2828
resp =
2929
HTTPoison.get(
30-
"localhost:8080/get?bar=zing&foo=first",
30+
"localhost:4002/get?bar=zing&foo=first",
3131
[],
3232
params: [{"foo", "second"}, {"baz", "bong"}]
3333
)
@@ -41,106 +41,106 @@ defmodule HTTPoisonTest do
4141

4242
assert Request.to_curl(response.request) ==
4343
{:ok,
44-
"curl -X GET http://localhost:8080/get?bar=zing&foo=first&foo=second&baz=bong"}
44+
"curl -X GET http://localhost:4002/get?bar=zing&foo=first&foo=second&baz=bong"}
4545
end)
4646
end
4747

4848
test "head" do
49-
assert_response(HTTPoison.head("localhost:8080/get"), fn response ->
49+
assert_response(HTTPoison.head("localhost:4002/get"), fn response ->
5050
assert response.body == ""
51-
assert Request.to_curl(response.request) == {:ok, "curl -X HEAD http://localhost:8080/get"}
51+
assert Request.to_curl(response.request) == {:ok, "curl -X HEAD http://localhost:4002/get"}
5252
end)
5353
end
5454

5555
test "post charlist body" do
56-
assert_response(HTTPoison.post("localhost:8080/post", 'test'), fn response ->
57-
assert Request.to_curl(response.request) == {:ok, "curl -X POST http://localhost:8080/post"}
56+
assert_response(HTTPoison.post("localhost:4002/post", 'test'), fn response ->
57+
assert Request.to_curl(response.request) == {:ok, "curl -X POST http://localhost:4002/post"}
5858
end)
5959
end
6060

6161
test "post binary body" do
6262
{:ok, file} = File.read(fixture_path("image.png"))
6363

64-
assert_response(HTTPoison.post("localhost:8080/post", file), fn response ->
64+
assert_response(HTTPoison.post("localhost:4002/post", file), fn response ->
6565
assert Request.to_curl(response.request) ==
66-
{:ok, "curl -X POST -d '#{file}' http://localhost:8080/post"}
66+
{:ok, "curl -X POST -d '#{file}' http://localhost:4002/post"}
6767
end)
6868
end
6969

7070
test "post form data" do
7171
assert_response(
72-
HTTPoison.post("localhost:8080/post", {:form, [key: "value"]}, %{
72+
HTTPoison.post("localhost:4002/post", {:form, [key: "value"]}, %{
7373
"Content-type" => "application/x-www-form-urlencoded"
7474
}),
7575
fn response ->
7676
Regex.match?(~r/"key".*"value"/, response.body)
7777

7878
assert Request.to_curl(response.request) ==
7979
{:ok,
80-
"curl -X POST -H 'Content-type: application/x-www-form-urlencoded' -F 'key=value' http://localhost:8080/post"}
80+
"curl -X POST -H 'Content-type: application/x-www-form-urlencoded' -F 'key=value' http://localhost:4002/post"}
8181
end
8282
)
8383
end
8484

8585
test "put" do
86-
assert_response(HTTPoison.put("localhost:8080/put", "test"), fn response ->
86+
assert_response(HTTPoison.put("localhost:4002/put", "test"), fn response ->
8787
assert Request.to_curl(response.request) ==
88-
{:ok, "curl -X PUT -d 'test' http://localhost:8080/put"}
88+
{:ok, "curl -X PUT -d 'test' http://localhost:4002/put"}
8989
end)
9090
end
9191

9292
test "put without body" do
93-
assert_response(HTTPoison.put("localhost:8080/put"), fn response ->
93+
assert_response(HTTPoison.put("localhost:4002/put"), fn response ->
9494
assert Request.to_curl(response.request) ==
95-
{:ok, "curl -X PUT http://localhost:8080/put"}
95+
{:ok, "curl -X PUT http://localhost:4002/put"}
9696
end)
9797
end
9898

9999
test "patch" do
100-
assert_response(HTTPoison.patch("localhost:8080/patch", "test"), fn response ->
100+
assert_response(HTTPoison.patch("localhost:4002/patch", "test"), fn response ->
101101
assert Request.to_curl(response.request) ==
102-
{:ok, "curl -X PATCH -d 'test' http://localhost:8080/patch"}
102+
{:ok, "curl -X PATCH -d 'test' http://localhost:4002/patch"}
103103
end)
104104
end
105105

106106
test "delete" do
107-
assert_response(HTTPoison.delete("localhost:8080/delete"), fn response ->
107+
assert_response(HTTPoison.delete("localhost:4002/delete"), fn response ->
108108
assert Request.to_curl(response.request) ==
109-
{:ok, "curl -X DELETE http://localhost:8080/delete"}
109+
{:ok, "curl -X DELETE http://localhost:4002/delete"}
110110
end)
111111
end
112112

113113
test "options" do
114-
assert_response(HTTPoison.options("localhost:8080/get"), fn response ->
114+
assert_response(HTTPoison.options("localhost:4002/get"), fn response ->
115115
assert get_header(response.headers, "content-length") == "0"
116116
assert is_binary(get_header(response.headers, "allow"))
117117

118118
assert Request.to_curl(response.request) ==
119-
{:ok, "curl -X OPTIONS http://localhost:8080/get"}
119+
{:ok, "curl -X OPTIONS http://localhost:4002/get"}
120120
end)
121121
end
122122

123123
test "option follow redirect absolute url" do
124124
assert_response(
125125
HTTPoison.get(
126-
"http://localhost:8080/redirect-to?url=http%3A%2F%2Flocalhost:8080%2Fget",
126+
"http://localhost:4002/redirect-to?url=http%3A%2F%2Flocalhost:4002%2Fget",
127127
[],
128128
follow_redirect: true
129129
),
130130
fn response ->
131131
assert Request.to_curl(response.request) ==
132132
{:ok,
133-
"curl -L --max-redirs 5 -X GET http://localhost:8080/redirect-to?url=http%3A%2F%2Flocalhost:8080%2Fget"}
133+
"curl -L --max-redirs 5 -X GET http://localhost:4002/redirect-to?url=http%3A%2F%2Flocalhost:4002%2Fget"}
134134
end
135135
)
136136
end
137137

138138
test "option follow redirect relative url" do
139139
assert_response(
140-
HTTPoison.get("http://localhost:8080/relative-redirect/1", [], follow_redirect: true),
140+
HTTPoison.get("http://localhost:4002/relative-redirect/1", [], follow_redirect: true),
141141
fn response ->
142142
assert Request.to_curl(response.request) ==
143-
{:ok, "curl -L --max-redirs 5 -X GET http://localhost:8080/relative-redirect/1"}
143+
{:ok, "curl -L --max-redirs 5 -X GET http://localhost:4002/relative-redirect/1"}
144144
end
145145
)
146146
end
@@ -149,14 +149,14 @@ defmodule HTTPoisonTest do
149149
hackney = [basic_auth: {"user", "pass"}]
150150

151151
assert_response(
152-
HTTPoison.get("http://localhost:8080/basic-auth/user/pass", [], hackney: hackney)
152+
HTTPoison.get("http://localhost:4002/basic-auth/user/pass", [], hackney: hackney)
153153
)
154154
end
155155

156156
test "explicit http scheme" do
157-
assert_response(HTTPoison.head("http://localhost:8080/get"), fn response ->
157+
assert_response(HTTPoison.head("http://localhost:4002/get"), fn response ->
158158
assert Request.to_curl(response.request) ==
159-
{:ok, "curl -X HEAD http://localhost:8080/get"}
159+
{:ok, "curl -X HEAD http://localhost:4002/get"}
160160
end)
161161
end
162162

@@ -181,44 +181,44 @@ defmodule HTTPoisonTest do
181181
end
182182

183183
test "char list URL" do
184-
assert_response(HTTPoison.head('localhost:8080/get'), fn response ->
184+
assert_response(HTTPoison.head('localhost:4002/get'), fn response ->
185185
assert Request.to_curl(response.request) ==
186-
{:ok, "curl -X HEAD http://localhost:8080/get"}
186+
{:ok, "curl -X HEAD http://localhost:4002/get"}
187187
end)
188188
end
189189

190190
test "request headers as a map" do
191191
map_header = %{"X-Header" => "X-Value"}
192-
assert response = HTTPoison.get!("localhost:8080/get", map_header)
192+
assert response = HTTPoison.get!("localhost:4002/get", map_header)
193193
assert response.body =~ "X-Value"
194194

195195
assert Request.to_curl(response.request) ==
196-
{:ok, "curl -X GET -H 'X-Header: X-Value' http://localhost:8080/get"}
196+
{:ok, "curl -X GET -H 'X-Header: X-Value' http://localhost:4002/get"}
197197
end
198198

199199
test "cached request" do
200200
if_modified = %{"If-Modified-Since" => "Tue, 11 Dec 2012 10:10:24 GMT"}
201-
response = HTTPoison.get!("localhost:8080/cache", if_modified)
201+
response = HTTPoison.get!("localhost:4002/cache", if_modified)
202202
assert %HTTPoison.Response{status_code: 304, body: ""} = response
203203

204204
assert Request.to_curl(response.request) ==
205205
{:ok,
206-
"curl -X GET -H 'If-Modified-Since: Tue, 11 Dec 2012 10:10:24 GMT' http://localhost:8080/cache"}
206+
"curl -X GET -H 'If-Modified-Since: Tue, 11 Dec 2012 10:10:24 GMT' http://localhost:4002/cache"}
207207
end
208208

209209
test "send cookies" do
210-
response = HTTPoison.get!("localhost:8080/cookies", %{}, hackney: [cookie: ["foo=1; bar=2"]])
210+
response = HTTPoison.get!("localhost:4002/cookies", %{}, hackney: [cookie: ["foo=1; bar=2"]])
211211
assert Jason.decode!(response.body) == %{"cookies" => %{"foo" => "1", "bar" => "2"}}
212212
end
213213

214214
test "receive cookies" do
215-
response = HTTPoison.get!("localhost:8080/cookies/set?foo=1&bar=2")
215+
response = HTTPoison.get!("localhost:4002/cookies/set?foo=1&bar=2")
216216
has_foo = Enum.member?(response.headers, {"set-cookie", "foo=1; Version=1; Path=/"})
217217
has_bar = Enum.member?(response.headers, {"set-cookie", "bar=2; Version=1; Path=/"})
218218
assert has_foo and has_bar
219219

220220
assert Request.to_curl(response.request) ==
221-
{:ok, "curl -X GET http://localhost:8080/cookies/set?foo=1&bar=2"}
221+
{:ok, "curl -X GET http://localhost:4002/cookies/set?foo=1&bar=2"}
222222
end
223223

224224
test "exception" do
@@ -231,7 +231,7 @@ defmodule HTTPoisonTest do
231231

232232
test "asynchronous request" do
233233
{:ok, %HTTPoison.AsyncResponse{id: id}} =
234-
HTTPoison.get("localhost:8080/get", [], stream_to: self())
234+
HTTPoison.get("localhost:4002/get", [], stream_to: self())
235235

236236
assert_receive %HTTPoison.AsyncStatus{id: ^id, code: 200}, 1_000
237237
assert_receive %HTTPoison.AsyncHeaders{id: ^id, headers: headers}, 1_000
@@ -242,7 +242,7 @@ defmodule HTTPoisonTest do
242242

243243
test "asynchronous request with explicit streaming using [async: :once]" do
244244
{:ok, resp = %HTTPoison.AsyncResponse{id: id}} =
245-
HTTPoison.get("localhost:8080/get", [], stream_to: self(), async: :once)
245+
HTTPoison.get("localhost:4002/get", [], stream_to: self(), async: :once)
246246

247247
assert_receive %HTTPoison.AsyncStatus{id: ^id, code: 200}, 100
248248

@@ -264,21 +264,21 @@ defmodule HTTPoisonTest do
264264
test "asynchronous redirected get request" do
265265
{:ok, %HTTPoison.AsyncResponse{id: id}} =
266266
HTTPoison.get(
267-
"localhost:8080/redirect/2",
267+
"localhost:4002/redirect/2",
268268
[],
269269
stream_to: self(),
270270
hackney: [follow_redirect: true]
271271
)
272272

273273
assert_receive %HTTPoison.AsyncRedirect{id: ^id, to: to, headers: headers}, 1_000
274-
assert to == "http://localhost:8080/redirect/1"
274+
assert to == "http://localhost:4002/redirect/1"
275275
assert is_list(headers)
276276
end
277277

278278
test "multipart upload" do
279279
response =
280280
HTTPoison.post(
281-
"localhost:8080/post",
281+
"localhost:4002/post",
282282
{:multipart, [{:file, "test/test_helper.exs"}, {"name", "value"}]}
283283
)
284284

@@ -289,14 +289,14 @@ defmodule HTTPoisonTest do
289289
expected = %{"some" => "bytes"}
290290
enumerable = Jason.encode!(expected) |> String.split("")
291291
headers = %{"Content-type" => "application/json"}
292-
response = HTTPoison.post("localhost:8080/post", {:stream, enumerable}, headers)
292+
response = HTTPoison.post("localhost:4002/post", {:stream, enumerable}, headers)
293293

294294
assert_response(response, fn response ->
295295
assert Jason.decode!(response.body)["json"] == expected
296296

297297
assert Request.to_curl(response.request) ==
298298
{:ok,
299-
"curl -X POST -H 'Content-type: application/json' -d '{\"some\":\"bytes\"}' http://localhost:8080/post"}
299+
"curl -X POST -H 'Content-type: application/json' -d '{\"some\":\"bytes\"}' http://localhost:4002/post"}
300300
end)
301301
end
302302

@@ -312,7 +312,7 @@ defmodule HTTPoisonTest do
312312
|> Kernel.*(buffer_size)
313313
|> Kernel.trunc()
314314

315-
resp = HTTPoison.get("localhost:8080/stream/20", [], max_body_length: max_length)
315+
resp = HTTPoison.get("localhost:4002/stream/20", [], max_body_length: max_length)
316316

317317
assert_response(resp, fn response ->
318318
assert byte_size(response.body) <= expected_length

0 commit comments

Comments
 (0)