@@ -305,4 +305,75 @@ defmodule Tesla.Adapter.MintTest do
305305 read_body ( conn , ref , opts , acc <> part )
306306 end
307307 end
308+
309+ describe "response handling - issue #450 fix" do
310+ test "adapter handles normal requests without crashes" do
311+ request = % Env {
312+ method: :get ,
313+ url: "#{ @ http } /get"
314+ }
315+
316+ assert { :ok , % Env { } = response } = call ( request )
317+ assert response . status == 200
318+ end
319+
320+ test "adapter handles connection errors gracefully" do
321+ request = % Env {
322+ method: :get ,
323+ url: "#{ @ http } /status/500"
324+ }
325+
326+ assert { :ok , % Env { } = response } = call ( request )
327+ assert response . status == 500
328+ end
329+
330+ test "adapter handles timeout scenarios" do
331+ request = % Env {
332+ method: :get ,
333+ url: "#{ @ http } /delay/1"
334+ }
335+
336+ assert { :error , :timeout } = call ( request , timeout: 100 )
337+ end
338+
339+ test "adapter handles streaming responses" do
340+ request = % Env {
341+ method: :get ,
342+ url: "#{ @ http } /stream-bytes/100"
343+ }
344+
345+ assert { :ok , % Env { } = response } = call ( request , body_as: :stream )
346+ assert response . status == 200
347+ assert is_function ( response . body )
348+
349+ data = Enum . join ( response . body )
350+ assert byte_size ( data ) > 0
351+ end
352+
353+ test "adapter handles chunked responses" do
354+ request = % Env {
355+ method: :get ,
356+ url: "#{ @ http } /stream-bytes/50"
357+ }
358+
359+ assert { :ok , % Env { } = response } = call ( request , body_as: :chunks )
360+ assert response . status == 200
361+
362+ % { conn: conn , ref: ref , opts: opts , body: body } = response . body
363+
364+ { :ok , _conn , received_body } = read_body ( conn , ref , opts , body )
365+ assert byte_size ( received_body ) > 0
366+ end
367+
368+ test "adapter handles large responses without crashes" do
369+ request = % Env {
370+ method: :get ,
371+ url: "#{ @ http } /stream-bytes/1000"
372+ }
373+
374+ assert { :ok , % Env { } = response } = call ( request )
375+ assert response . status == 200
376+ assert byte_size ( response . body ) > 1000
377+ end
378+ end
308379end
0 commit comments