Current section
Files
Jump to
Current section
Files
src/scrapbook@internal@http.erl
-module(scrapbook@internal@http).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/scrapbook/internal/http.gleam").
-export([construct_request/2]).
-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/scrapbook/internal/http.gleam", 5).
?DOC(false).
-spec construct_request(binary(), binary()) -> {ok,
gleam@http@request:request(binary())} |
{error, scrapbook@error:request_error()}.
construct_request(Url, User_agent) ->
gleam@result:'try'(
gleam@result:replace_error(
gleam@http@request:to(Url),
{construction_error, Url}
),
fun(Req) ->
Req@1 = begin
_pipe = Req,
_pipe@1 = gleam@http@request:set_header(
_pipe,
<<"accept"/utf8>>,
<<"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"/utf8>>
),
_pipe@2 = gleam@http@request:set_header(
_pipe@1,
<<"accept-language"/utf8>>,
<<"en-US,en;q=0.6"/utf8>>
),
_pipe@3 = gleam@http@request:set_header(
_pipe@2,
<<"cache-control"/utf8>>,
<<"max-age=0"/utf8>>
),
_pipe@4 = gleam@http@request:set_header(
_pipe@3,
<<"sec-fetch-dest"/utf8>>,
<<"document"/utf8>>
),
_pipe@5 = gleam@http@request:set_header(
_pipe@4,
<<"sec-fetch-mode"/utf8>>,
<<"navigate"/utf8>>
),
_pipe@6 = gleam@http@request:set_header(
_pipe@5,
<<"sec-fetch-site"/utf8>>,
<<"same-origin"/utf8>>
),
_pipe@7 = gleam@http@request:set_header(
_pipe@6,
<<"sec-fetch-user"/utf8>>,
<<"?1"/utf8>>
),
_pipe@8 = gleam@http@request:set_header(
_pipe@7,
<<"sec-gpc"/utf8>>,
<<"1"/utf8>>
),
_pipe@9 = gleam@http@request:set_header(
_pipe@8,
<<"upgrade-insecure-requests"/utf8>>,
<<"1"/utf8>>
),
gleam@http@request:set_header(
_pipe@9,
<<"user-agent"/utf8>>,
User_agent
)
end,
{ok, Req@1}
end
).