Skip to content

Commit 00750fd

Browse files
committed
HTTP cleanup
1 parent 9ab9be8 commit 00750fd

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

lib/hexdocs/http.ex

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ defmodule Hexdocs.HTTP do
88
:hackney.head(url, headers)
99
end
1010

11-
def get(url, headers) do
12-
:hackney.get(url, headers)
11+
def get(url, headers, opts \\ []) do
12+
:hackney.get(url, headers, "", opts)
1313
|> read_response()
1414
end
1515

@@ -24,12 +24,8 @@ defmodule Hexdocs.HTTP do
2424
end
2525

2626
def post(url, headers, body, opts \\ []) do
27-
if :with_body in opts do
28-
:hackney.post(url, headers, body, opts)
29-
else
30-
:hackney.post(url, headers, body, opts)
31-
|> read_response()
32-
end
27+
:hackney.post(url, headers, body, opts)
28+
|> read_response()
3329
end
3430

3531
def delete(url, headers, opts \\ []) do

lib/hexdocs/search/typesense.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule Hexdocs.Search.Typesense do
2929
url = url("collections/#{collection()}/documents/import?action=create")
3030
headers = [{"x-typesense-api-key", api_key()}]
3131

32-
case HTTP.post(url, headers, ndjson, [:with_body, recv_timeout: @timeout]) do
32+
case HTTP.post(url, headers, ndjson, recv_timeout: @timeout) do
3333
{:ok, 200, _resp_headers, ndjson} ->
3434
ndjson
3535
|> String.split("\n")

lib/hexdocs/source_repo/github.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ defmodule Hexdocs.SourceRepo.GitHub do
99
url = @github_url <> "/repos/#{repo}/tags"
1010

1111
headers = [
12-
accept: "application/json"
12+
{"accept", "application/json"}
1313
]
1414

1515
options = [
16-
:with_body,
1716
basic_auth: {user, token}
1817
]
1918

2019
Hexdocs.HTTP.retry("github", url, fn ->
21-
:hackney.get(url, headers, "", options)
20+
Hexdocs.HTTP.get(url, headers, options)
2221
end)
2322
|> case do
2423
{:ok, 200, _headers, body} ->

0 commit comments

Comments
 (0)