@@ -305,4 +305,59 @@ defmodule Tesla.Adapter.MintTest do
305305 read_body ( conn , ref , opts , acc <> part )
306306 end
307307 end
308+
309+ describe "issue #450 - adapter doesn't crash on unsupported response types" do
310+ test "handles connection errors gracefully" do
311+ uri = URI . parse ( @ http )
312+
313+ request = % Env {
314+ method: :get ,
315+ url: "http://#{ uri . host } :1234"
316+ }
317+
318+ assert { :error , _reason } = call ( request )
319+ end
320+
321+ test "handles malformed requests without crashes" do
322+ request = % Env {
323+ method: :get ,
324+ url: "#{ @ http } /status/500"
325+ }
326+
327+ assert { :ok , % Env { } = response } = call ( request )
328+ assert response . status == 500
329+ end
330+
331+ test "handles timeout scenarios without crashes" do
332+ request = % Env {
333+ method: :get ,
334+ url: "#{ @ http } /delay/2"
335+ }
336+
337+ assert { :error , :timeout } = call ( request , timeout: 100 )
338+ end
339+
340+ test "handles connection drops during streaming" do
341+ request = % Env {
342+ method: :get ,
343+ url: "#{ @ http } /stream-bytes/1000"
344+ }
345+
346+ assert { :ok , % Env { } = response } = call ( request , body_as: :stream )
347+ assert response . status == 200
348+
349+ data = Enum . join ( response . body )
350+ assert byte_size ( data ) > 0
351+ end
352+
353+ test "handles HTTP/2 connections when available" do
354+ request = % Env {
355+ method: :get ,
356+ url: "#{ @ http } /get"
357+ }
358+
359+ assert { :ok , % Env { } = response } = call ( request )
360+ assert response . status == 200
361+ end
362+ end
308363end
0 commit comments