Skip to content

Commit

Permalink
Proper HTTP response
Browse files Browse the repository at this point in the history
  • Loading branch information
cvincent committed Nov 26, 2024
1 parent 7f40db0 commit fa656fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ha_notifier/listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit fa656fa

Please sign in to comment.