From fa656fabbe2a05c0cf53766810096a4c6891497c Mon Sep 17 00:00:00 2001 From: Chris Vincent Date: Mon, 25 Nov 2024 21:14:51 -0600 Subject: [PATCH] Proper HTTP response --- lib/ha_notifier/listener.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ha_notifier/listener.ex b/lib/ha_notifier/listener.ex index 42ecce5..9725a5e 100644 --- a/lib/ha_notifier/listener.ex +++ b/lib/ha_notifier/listener.ex @@ -26,6 +26,7 @@ defmodule HANotifier.Listener do defp serve(client) do {:ok, data} = :gen_tcp.recv(client, 0) + Logger.info("recv: #{String.trim(data)}") handle_line(client, data) end @@ -49,7 +50,9 @@ defmodule HANotifier.Listener do end defp handle_line(client, "\r\n") do - :gen_tcp.send(client, "HTTP/1.1 200 OK") + :gen_tcp.send(client, "HTTP/1.1 200 OK\r\n") + :gen_tcp.send(client, "Content-Type: text/plain\r\n") + :gen_tcp.send(client, "Content-Length: 0\r\n") :gen_tcp.send(client, "\r\n") end