Skip to content

Commit 530ba27

Browse files
authored
Deprecate :read_write option on HTTP.open?/2 (#426)
1 parent 23b431b commit 530ba27

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

lib/mint/core/conn.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule Mint.Core.Conn do
1313
keyword()
1414
) :: {:ok, conn()} | {:error, Types.error()}
1515

16-
@callback open?(conn(), :read | :write | :read_write) :: boolean()
16+
@callback open?(conn(), :read | :write) :: boolean()
1717

1818
@callback close(conn()) :: {:ok, conn()}
1919

lib/mint/http.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,16 @@ defmodule Mint.HTTP do
509509
either open, or closed (for both reading and writing). In HTTP/2, the connection can be closed only
510510
for writing but not for reading, meaning that you cannot send any more data to the
511511
server but you can still receive data from the server. In this case, `Mint.HTTP.open?(conn, :read)`
512-
would return `true` but `Mint.HTTP.open?(conn, :read_write)` would return `false`.
512+
would return `true` but `Mint.HTTP.open?(conn, :write)` would return `false`.
513513
See the "Closed connection" section in the module documentation of `Mint.HTTP2`.
514514
515515
If a connection is *completely closed* (that is, `Mint.HTTP.open?(conn, :read)` returns `false`),
516516
it has become useless and you should get rid of it. If you still need a connection
517517
to the server, start a new connection with `connect/4`.
518518
519-
> #### The default value of `type` is `:read_write` {: .warning}
519+
> #### The default value of `type` is `:write` {: .warning}
520520
>
521-
> With the default value of `type` being `:read_write`, a call to
521+
> With the default value of `type` being `:write`, a call to
522522
> `Mint.HTTP.open?(conn)` will return `false` if `conn` was closed for writing
523523
> but is still open for reading. If you need to make sure the connection is
524524
> completely closed, check that `Mint.HTTP.open?(conn, :read)` returns `false`.
@@ -531,8 +531,8 @@ defmodule Mint.HTTP do
531531
532532
"""
533533
@impl true
534-
@spec open?(t(), :read | :write | :read_write) :: boolean()
535-
def open?(conn, type \\ :read_write), do: conn_module(conn).open?(conn, type)
534+
@spec open?(t(), :read | :write) :: boolean()
535+
def open?(conn, type \\ :write), do: conn_module(conn).open?(conn, type)
536536

537537
@doc """
538538
Sends a request to the connected server.

lib/mint/http1.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,10 @@ defmodule Mint.HTTP1 do
231231
See `Mint.HTTP.open?/1`.
232232
"""
233233
@impl true
234-
@spec open?(t(), :read | :write | :read_write) :: boolean()
235-
def open?(conn, type \\ :read_write)
234+
@spec open?(t(), :read | :write) :: boolean()
235+
def open?(conn, type \\ :write)
236236

237+
# TODO: hard-deprecate :read_write in 1.7.
237238
def open?(%__MODULE__{state: state}, type) when type in [:read, :write, :read_write] do
238239
state == :open
239240
end

lib/mint/http2.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ defmodule Mint.HTTP2 do
448448
See `Mint.HTTP.open?/1`.
449449
"""
450450
@impl true
451-
@spec open?(t(), :read | :write | :read_write) :: boolean()
452-
def open?(%__MODULE__{state: state} = _conn, type \\ :read_write)
451+
@spec open?(t(), :read | :write) :: boolean()
452+
def open?(%__MODULE__{state: state} = _conn, type \\ :write)
453453
when type in [:read, :write, :read_write] do
454454
case state do
455455
:handshaking -> true

lib/mint/unsafe_proxy.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ defmodule Mint.UnsafeProxy do
5858
end
5959

6060
@impl true
61-
@spec open?(t(), :read | :write | :read_write) :: boolean()
62-
def open?(%UnsafeProxy{module: module, state: state}, type \\ :read_write) do
61+
@spec open?(t(), :read | :write) :: boolean()
62+
def open?(%UnsafeProxy{module: module, state: state}, type \\ :write) do
6363
module.open?(state, type)
6464
end
6565

0 commit comments

Comments
 (0)