From bb79c7d0570ffb7cb088c91cf0b1c7d8cd880c4b Mon Sep 17 00:00:00 2001 From: Val Lorentz Date: Wed, 27 Mar 2024 10:23:08 +0100 Subject: [PATCH] Fix recv_timeout for login requests 5 seconds is too short for matrix.org --- lib/matrix_client/client.ex | 4 ++-- test/matrix_client/client_test.exs | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/matrix_client/client.ex b/lib/matrix_client/client.ex index 31bfb06..1f7ba09 100644 --- a/lib/matrix_client/client.ex +++ b/lib/matrix_client/client.ex @@ -78,7 +78,7 @@ defmodule M51.MatrixClient.Client do # Check the server supports password login url = base_url <> "/_matrix/client/r0/login" Logger.debug("(raw) GET #{url}") - response = httpoison.get!(url, [], timeout: @timeout) + response = httpoison.get!(url, [], timeout: @timeout, recv_timeout: @timeout) Logger.debug(Kernel.inspect(response)) case response do @@ -111,7 +111,7 @@ defmodule M51.MatrixClient.Client do url = base_url <> "/_matrix/client/r0/login" Logger.debug("(raw) POST #{url} " <> Kernel.inspect(body)) - response = httpoison.post!(url, body, [], timeout: @timeout) + response = httpoison.post!(url, body, [], timeout: @timeout, recv_timeout: @timeout) Logger.debug(Kernel.inspect(response)) case response do diff --git a/test/matrix_client/client_test.exs b/test/matrix_client/client_test.exs index 67a8e78..eca93a8 100644 --- a/test/matrix_client/client_test.exs +++ b/test/matrix_client/client_test.exs @@ -41,7 +41,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:get!, fn url, headers, options -> assert url == "https://matrix.example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] %HTTPoison.Response{ status_code: 200, @@ -53,7 +53,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:post!, fn url, body, headers, options -> assert url == "https://matrix.example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] assert Jason.decode!(body) == %{ "type" => "m.login.password", @@ -104,7 +104,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:get!, fn url, headers, options -> assert url == "https://example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] %HTTPoison.Response{ status_code: 404, @@ -145,7 +145,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:get!, fn url, headers, options -> assert url == "https://matrix.example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] %HTTPoison.Response{ status_code: 200, @@ -163,7 +163,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:post!, fn url, body, headers, options -> assert url == "https://matrix.example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] assert Jason.decode!(body) == %{ "type" => "m.login.password", @@ -228,7 +228,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:get!, fn url, headers, options -> assert url == "https://matrix.example.com/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] %HTTPoison.Response{ status_code: 200, @@ -249,7 +249,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:post!, fn url, body, headers, options -> assert url == "https://matrix.example.com/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] assert Jason.decode!(body) == %{ "type" => "m.login.password", @@ -312,7 +312,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:get!, fn url, headers, options -> assert url == "https://matrix.example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] %HTTPoison.Response{ status_code: 200, @@ -359,7 +359,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:get!, fn url, headers, options -> assert url == "https://matrix.example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] %HTTPoison.Response{ status_code: 200, @@ -377,7 +377,7 @@ defmodule M51.MatrixClient.ClientTest do |> expect(:post!, fn url, body, headers, options -> assert url == "https://matrix.example.org/_matrix/client/r0/login" assert headers == [] - assert options == [timeout: @timeout] + assert options == [timeout: @timeout, recv_timeout: @timeout] assert Jason.decode!(body) == %{ "type" => "m.login.password",