File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed
Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -1954,22 +1954,25 @@ defmodule Req.Steps do
19541954 end
19551955
19561956 defp format ( request , response ) do
1957+ # TODO: remove ` || ` when we require Elixir v1.13
1958+ path = request . url . path || ""
1959+
19571960 case Req.Response . get_header ( response , "content-type" ) do
19581961 [ content_type | _ ] ->
1959- # TODO: remove ` || ` when we require Elixir v1.13
1960- path = request . url . path || ""
1961-
19621962 case extensions ( content_type , path ) do
19631963 [ ext | _ ] -> ext
19641964 [ ] -> nil
19651965 end
19661966
19671967 [ ] ->
1968- [ ]
1968+ case extensions ( "application/octet-stream" , path ) do
1969+ [ ext | _ ] -> ext
1970+ [ ] -> nil
1971+ end
19691972 end
19701973 end
19711974
1972- defp extensions ( "application/octet-stream" , path ) do
1975+ defp extensions ( "application/octet-stream" <> _ , path ) do
19731976 if tgz? ( path ) do
19741977 [ "tgz" ]
19751978 else
Original file line number Diff line number Diff line change @@ -764,6 +764,28 @@ defmodule Req.StepsTest do
764764 assert Req . get! ( plug: plug , url: "/foo.tar" ) . body == files
765765 end
766766
767+ test "tar (path, content type with charset utf8)" do
768+ files = [ { ~c" foo.txt" , "bar" } ]
769+
770+ plug = fn conn ->
771+ conn
772+ |> Plug.Conn . put_resp_content_type ( "application/octet-stream" )
773+ |> Plug.Conn . send_resp ( 200 , create_tar ( files ) )
774+ end
775+
776+ assert Req . get! ( plug: plug , url: "/foo.tar" ) . body == files
777+ end
778+
779+ test "tar (path, no content-type)" do
780+ files = [ { ~c" foo.txt" , "bar" } ]
781+
782+ plug = fn conn ->
783+ Plug.Conn . send_resp ( conn , 200 , create_tar ( files ) )
784+ end
785+
786+ assert Req . get! ( plug: plug , url: "/foo.tar.gz" ) . body == files
787+ end
788+
767789 test "tar.gz (path)" do
768790 files = [ { ~c" foo.txt" , "bar" } ]
769791
You can’t perform that action at this time.
0 commit comments