From 81001dea3546279c4028540d0a081b14d199a368 Mon Sep 17 00:00:00 2001 From: Edward Zhou Date: Fri, 1 Jun 2018 23:32:14 +0800 Subject: [PATCH] fix utf8 characters serialization issue --- lib/exvcr/handler.ex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/exvcr/handler.ex b/lib/exvcr/handler.ex index ee2432a..3524d36 100644 --- a/lib/exvcr/handler.ex +++ b/lib/exvcr/handler.ex @@ -140,6 +140,7 @@ defmodule ExVCR.Handler do defp get_response_from_server(request, recorder, record?) do adapter = ExVCR.Recorder.options(recorder)[:adapter] response = :meck.passthrough(request) + |> convert_body |> adapter.hook_response_from_server if record? do raise_error_if_cassette_already_exists(recorder, inspect(request)) @@ -149,6 +150,11 @@ defmodule ExVCR.Handler do response end + defp convert_body(response) do + {status, code, headers, body} = response + {status, code, headers, IO.iodata_to_binary(body)} + end + defp ignore_request?(request, recorder) do ignore_localhost = ExVCR.Recorder.options(recorder)[:ignore_localhost] || ExVCR.Setting.get(:ignore_localhost) if ignore_localhost do