Skip to content

Commit 6b4f98f

Browse files
committed
Support Elixir ~> 1.12
Replace pinned variables in binary pattern sizes (^var) with :erlang.split_binary/2 to support both Elixir 1.12+ and 1.20+ without warnings.
1 parent 0bfcc86 commit 6b4f98f

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ 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(),

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)