Open nicoolas25 opened 10 years ago
Thank you for taking time on this. I'm having difficulty to take time for a while, but will be looking into this one.
It's not a bad idea to have an option to store JSON or erlang terms (binary file in this case?).
I stored it with :io.format('~w.', term)
and parsed it back with the :erl_{parser,scanner,..}
. It may exist a better technique out there...
Having serializer option sounds reasonable, but I'm wondering that whether it can be resolved by adding option (retain original char-list type) or additional meta information in the json file (store type information). Also, it seems the Ruby's VCR is taking custom serializer approach in addition to native YAML/JSON support. Please let me play around a little more.
With the JSON serializer I also noticed that when there is the same HTTP header multiple times like set-cookie
there is some loss too. Only one header is kept.
I stumbled upon this issue when vcr-ing the fetch of an image (JPEG) using HTTPoison. In the first run, everything works as expected, but on the second run (with data deserialized from JSON), the body: data
I get back is roughly twice the size and (after File.write!
) not a valid JPEG anymore.
I had issues using ExVCR because of transformations that have been made on the request / responses to save them. The JSON deserialization made all the strings as Elixir's
String
(no character list anymore) and my oauth lib (tim/erlang-oauth
), expected a character list :-( Do you see where my problem is?Why not using an Erlang representation instead of JSON? You'll avoid many conversions... I tried this idea here if you're interested: https://github.com/nicoolas25/exvcr
Thank you for this work. With my minor adjustments it is very usefull!