summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/polyjuice/client/endpoint.ex10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/polyjuice/client/endpoint.ex b/lib/polyjuice/client/endpoint.ex
index b75ee6c..41c0a86 100644
--- a/lib/polyjuice/client/endpoint.ex
+++ b/lib/polyjuice/client/endpoint.ex
@@ -87,8 +87,14 @@ defmodule Polyjuice.Client.Endpoint do
) :: any
def parse_response(%{} = endpoint_args, status_code, headers, body)
when is_integer(status_code) and is_list(headers) and is_binary(body) do
- # FIXME: check if content type is "application/json"
- with {:ok, json} <- Jason.decode(body) do
+ # make sure it's JSON content
+ with {_, "application/json"} <-
+ Enum.find(
+ headers,
+ {nil, nil},
+ fn {name, _} -> String.downcase(name, :ascii) == "content-type" end
+ ),
+ {:ok, json} <- Jason.decode(body) do
case status_code do
200 ->
Polyjuice.Client.Endpoint.BodyParser.parse(endpoint_args, json)