Packages

An LLM interaction library that makes you feel like a star

Current section

Files

Jump to
starlet src starlet@internal@http.erl
Raw

src/starlet@internal@http.erl

-module(starlet@internal@http).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/starlet/internal/http.gleam").
-export([set_optional_port/2, parse_retry_after/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/starlet/internal/http.gleam", 11).
?DOC(false).
-spec set_optional_port(
gleam@http@request:request(binary()),
gleam@option:option(integer())
) -> gleam@http@request:request(binary()).
set_optional_port(Req, Port) ->
case Port of
{some, P} ->
gleam@http@request:set_port(Req, P);
_ ->
Req
end.
-file("src/starlet/internal/http.gleam", 22).
?DOC(false).
-spec parse_retry_after(list({binary(), binary()})) -> gleam@option:option(integer()).
parse_retry_after(Headers) ->
_pipe = gleam@list:find(
Headers,
fun(H) ->
{K, _} = H,
string:lowercase(K) =:= <<"retry-after"/utf8>>
end
),
_pipe@1 = gleam@result:'try'(
_pipe,
fun(H@1) ->
{_, V} = H@1,
gleam_stdlib:parse_int(V)
end
),
gleam@option:from_result(_pipe@1).