Skip to content

Commit a9e5d0f

Browse files
committed
docs: Improve type specifications in HTTP.Response
- Change body type from String.t() to binary() (more accurate) - Change url type to URI.t() | nil (can be nil) - Change text/1 return type from String.t() to binary() - All type specs now correctly reflect actual data types - Dialyzer, Credo, and all tests passing
1 parent 2b15bd6 commit a9e5d0f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/http/response.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ defmodule HTTP.Response do
126126
status_text: String.t(),
127127
ok: boolean(),
128128
headers: HTTP.Headers.t(),
129-
body: String.t() | nil,
129+
body: binary() | nil,
130130
body_used: boolean(),
131-
url: URI.t(),
131+
url: URI.t() | nil,
132132
redirected: boolean(),
133133
type: response_type(),
134134
stream: pid() | nil
@@ -215,7 +215,7 @@ defmodule HTTP.Response do
215215
iex> HTTP.Response.text(response)
216216
"Hello"
217217
"""
218-
@spec text(t()) :: String.t()
218+
@spec text(t()) :: binary()
219219
def text(%__MODULE__{body: body, stream: nil}), do: body
220220

221221
def text(%__MODULE__{body: body, stream: stream} = response) do

0 commit comments

Comments
 (0)