@@ -69,8 +69,8 @@ defmodule Tesla.Test do
69
69
@ spec html ( % Tesla.Env { } , binary ) :: % Tesla.Env { }
70
70
def html ( % Tesla.Env { } = env , body ) when is_binary ( body ) do
71
71
env
72
- |> Tesla . put_body ( body )
73
- |> Tesla . put_headers ( [ { "content-type" , "text/html; charset=utf-8" } ] )
72
+ |> put_body ( body )
73
+ |> put_headers ( [ { "content-type" , "text/html; charset=utf-8" } ] )
74
74
end
75
75
76
76
@ doc """
@@ -91,8 +91,8 @@ defmodule Tesla.Test do
91
91
body = encode! ( body , "application/json" )
92
92
93
93
env
94
- |> Tesla . put_body ( body )
95
- |> Tesla . put_headers ( [ { "content-type" , "application/json; charset=utf-8" } ] )
94
+ |> put_body ( body )
95
+ |> put_headers ( [ { "content-type" , "application/json; charset=utf-8" } ] )
96
96
end
97
97
98
98
@ doc """
@@ -108,8 +108,8 @@ defmodule Tesla.Test do
108
108
@ spec text ( % Tesla.Env { } , binary ) :: % Tesla.Env { }
109
109
def text ( % Tesla.Env { } = env , body ) when is_binary ( body ) do
110
110
env
111
- |> Tesla . put_body ( body )
112
- |> Tesla . put_headers ( [ { "content-type" , "text/plain; charset=utf-8" } ] )
111
+ |> put_body ( body )
112
+ |> put_headers ( [ { "content-type" , "text/plain; charset=utf-8" } ] )
113
113
end
114
114
115
115
@ doc """
@@ -271,4 +271,16 @@ defmodule Tesla.Test do
271
271
adapter
272
272
end
273
273
end
274
+
275
+ defp put_body ( % Tesla.Env { } = env , body ) do
276
+ % { env | body: body }
277
+ end
278
+
279
+ defp put_headers ( % Tesla.Env { headers: nil } = env , headers ) when is_list ( headers ) do
280
+ % { env | headers: headers }
281
+ end
282
+
283
+ defp put_headers ( % Tesla.Env { } = env , headers ) when is_list ( headers ) do
284
+ % { env | headers: env . headers ++ headers }
285
+ end
274
286
end
0 commit comments