Elixir Finch not returning all of the tags, like the meta tags

Viewed 13

Elixir Finch is not returning all the headers I see when I visit a page.

Some of the tags are missing, in particular the meta tags.

I've tried using :httpc.request(:get, {url, []}, [], [])} as well to no avail.

Why am I not getting the meta tags?

1 Answers

I built a simple plug:

defmodule MyPlug do
  import Plug.Conn

  def init(options) do
    # initialize options
    options
  end

  def call(conn, _opts) do
    conn
    |> put_resp_header("meta", "foo")
    |> put_resp_content_type("text/plain")
    |> send_resp(200, "Hello world")
  end

  def get do
    Finch.build(:get, "http://localhost:4001") |> Finch.request(MyFinch)
  end
end

Calling it:

iex(1)> MyPlug.get
{:ok,
 %Finch.Response{
   status: 200,
   body: "Hello world",
   headers: [
     {"cache-control", "max-age=0, private, must-revalidate"},
     {"content-length", "11"},
     {"content-type", "text/plain; charset=utf-8"},
     {"date", "Sun, 25 Sep 2022 01:20:53 GMT"},
     {"meta", "foo"},
     {"server", "Cowboy"}
   ]
 }}

The meta header is returned.

Related