File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ defmodule ChromeRemoteInterface.HTTP do
2828 defp handle_response ( { :ok , status_code , _response_headers , client_ref } ) do
2929 with true <- status_code >= 200 && status_code < 300 ,
3030 { :ok , body } <- :hackney . body ( client_ref ) ,
31- { :ok , json } <- format_body ( body ) |> Poison . decode ( ) do
31+ { :ok , formatted_body } <- format_body ( body ) ,
32+ { :ok , json } <- decode ( formatted_body ) do
3233 { :ok , json }
3334 else
3435 error -> error
@@ -43,6 +44,13 @@ defmodule ChromeRemoteInterface.HTTP do
4344 { :error , reason }
4445 end
4546
46- defp format_body ( "" ) , do: "{}"
47- defp format_body ( body ) , do: body
47+ defp format_body ( "" ) , do: format_body ( "{}" )
48+ defp format_body ( body ) , do: { :ok , body }
49+
50+ defp decode ( body ) do
51+ case Poison . decode ( body ) do
52+ { :ok , json } -> { :ok , json }
53+ { :error , _reason } -> { :ok , body }
54+ end
55+ end
4856end
You can’t perform that action at this time.
0 commit comments