aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/http/http.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/http/http.ex')
-rw-r--r--lib/pleroma/http/http.ex8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex
index 583b56484..66ca75367 100644
--- a/lib/pleroma/http/http.ex
+++ b/lib/pleroma/http/http.ex
@@ -16,6 +16,7 @@ defmodule Pleroma.HTTP do
require Logger
@type t :: __MODULE__
+ @type method() :: :get | :post | :put | :delete | :head
@doc """
Performs GET request.
@@ -28,6 +29,9 @@ defmodule Pleroma.HTTP do
def get(nil, _, _), do: nil
def get(url, headers, options), do: request(:get, url, "", headers, options)
+ @spec head(Request.url(), Request.headers(), keyword()) :: {:ok, Env.t()} | {:error, any()}
+ def head(url, headers \\ [], options \\ []), do: request(:head, url, "", headers, options)
+
@doc """
Performs POST request.
@@ -42,7 +46,7 @@ defmodule Pleroma.HTTP do
Builds and performs http request.
# Arguments:
- `method` - :get, :post, :put, :delete
+ `method` - :get, :post, :put, :delete, :head
`url` - full url
`body` - request body
`headers` - a keyworld list of headers, e.g. `[{"content-type", "text/plain"}]`
@@ -52,7 +56,7 @@ defmodule Pleroma.HTTP do
`{:ok, %Tesla.Env{}}` or `{:error, error}`
"""
- @spec request(atom(), Request.url(), String.t(), Request.headers(), keyword()) ::
+ @spec request(method(), Request.url(), String.t(), Request.headers(), keyword()) ::
{:ok, Env.t()} | {:error, any()}
def request(method, url, body, headers, options) when is_binary(url) do
uri = URI.parse(url)