Skip to content

Commit

Permalink
fix for 'Content-Encoding: gzip' errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinon committed Sep 2, 2019
1 parent 4a281ac commit f9611d2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: vcr
version: 0.2.1
version: 0.2.2

authors:
- Holden Omans <[email protected]>
Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ require "spec"
require "../src/vcr"

require "halite"
require "file_utils"

FileUtils.rm_rf("./spec/fixtures/vcr/cassette-one")
11 changes: 9 additions & 2 deletions src/ext/http_client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ class HTTP::Client
else
response = orig_exec_internal_single(request)
unless response.nil?
io = IO::Memory.new
cassette_file = File.open(cassette_path, "w+")
response.to_io(cassette_file)
cassette_file.flush
response.to_io(io)
io.rewind

cassette_file = File.open(cassette_path, "w+")
io.each_line do |line|
cassette_file.puts(line) unless line =~ /Content-Encoding: gzip/
end
cassette_file.close

return response
end
Expand Down
2 changes: 1 addition & 1 deletion src/vcr/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module VCR
VERSION = "0.2.1"
VERSION = "0.2.2"
end

0 comments on commit f9611d2

Please sign in to comment.