Skip to content

Commit 1a82c1d

Browse files
authored
Support Elixir ~> 1.12 (#478)
1 parent 2a78a5b commit 1a82c1d

8 files changed

Lines changed: 17 additions & 37 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
# One version down.
2323
- erlang: "27.2"
2424
elixir: "1.18"
25-
# Oldest version. We technically support OTP 23 but hard to test in CI
25+
# Oldest version.
2626
- erlang: "24.3"
27-
elixir: "1.15"
27+
elixir: "1.12.3"
2828

2929
env:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

lib/mint/application.ex

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/mint/core/transport/ssl.ex

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -601,18 +601,14 @@ defmodule Mint.Core.Transport.SSL do
601601
end
602602

603603
defp get_cacertfile(path) do
604-
if Application.get_env(:mint, :persistent_term) do
605-
case :persistent_term.get({:mint, {:cacertfile, path}}, :error) do
606-
{:ok, cacerts} ->
607-
cacerts
608-
609-
:error ->
610-
cacerts = decode_cacertfile(path)
611-
:persistent_term.put({:mint, {:cacertfile, path}}, {:ok, cacerts})
612-
cacerts
613-
end
614-
else
615-
decode_cacertfile(path)
604+
case :persistent_term.get({:mint, {:cacertfile, path}}, :error) do
605+
{:ok, cacerts} ->
606+
cacerts
607+
608+
:error ->
609+
cacerts = decode_cacertfile(path)
610+
:persistent_term.put({:mint, {:cacertfile, path}}, {:ok, cacerts})
611+
cacerts
616612
end
617613
end
618614

lib/mint/http1.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ defmodule Mint.HTTP1 do
762762
{:ok, conn, responses}
763763

764764
length <= byte_size(data) ->
765-
<<body::binary-size(^length), rest::binary>> = data
765+
{body, rest} = :erlang.split_binary(data, length)
766766
{conn, responses} = add_body(conn, body, responses)
767767
conn = request_done(conn)
768768
responses = [{:done, request_ref} | responses]
@@ -836,7 +836,7 @@ defmodule Mint.HTTP1 do
836836
{:ok, conn, responses}
837837

838838
length <= byte_size(data) ->
839-
<<body::binary-size(^length), rest::binary>> = data
839+
{body, rest} = :erlang.split_binary(data, length)
840840
{conn, responses} = add_body(conn, body, responses)
841841
conn = put_in(conn.request.body, {:chunked, :crlf})
842842
decode_body({:chunked, :crlf}, conn, rest, request_ref, responses)

lib/mint/http2.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ defmodule Mint.HTTP2 do
12661266
end
12671267

12681268
defp split_payload_in_chunks(binary, chunk_size, acc) do
1269-
<<chunk::size(^chunk_size)-binary, rest::binary>> = binary
1269+
{chunk, rest} = :erlang.split_binary(binary, chunk_size)
12701270
split_payload_in_chunks(rest, chunk_size, [chunk | acc])
12711271
end
12721272

lib/mint/http2/frame.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ defmodule Mint.HTTP2.Frame do
271271
else
272272
# 1 byte is for the space taken by pad_length
273273
data_length = byte_size(payload) - pad_length - 1
274-
<<data::size(^data_length)-binary, padding::size(^pad_length)-binary>> = rest
274+
{data, padding} = :erlang.split_binary(rest, data_length)
275275
{data, padding}
276276
end
277277
end

mix.exs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ defmodule Mint.MixProject do
88
[
99
app: :mint,
1010
version: @version,
11-
elixir: "~> 1.15",
11+
elixir: "~> 1.12",
1212
start_permanent: Mix.env() == :prod,
1313
elixirc_paths: elixirc_paths(Mix.env()),
1414
deps: deps(),
1515

1616
# Xref
1717
xref: [
1818
exclude: [
19-
:persistent_term,
2019
{:ssl, :cipher_suites, 1},
2120
{:public_key, :cacerts_get, 0},
2221
CAStore
@@ -54,8 +53,7 @@ defmodule Mint.MixProject do
5453
# Run "mix help compile.app" to learn about applications.
5554
def application do
5655
[
57-
extra_applications: [:logger, :ssl],
58-
mod: {Mint.Application, []}
56+
extra_applications: [:logger, :ssl]
5957
]
6058
end
6159

test/mint/http1/conn_properties_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule Mint.HTTP1.PropertiesTest do
9090
|> Enum.sort()
9191
|> Enum.reduce({[], binary, 0}, fn split, {chunks, rest, prev_split} ->
9292
length = split - prev_split
93-
<<chunk::binary-size(^length), rest::binary>> = rest
93+
{chunk, rest} = :erlang.split_binary(rest, length)
9494
{[chunk | chunks], rest, split}
9595
end)
9696
|> join_last_chunk()

0 commit comments

Comments
 (0)