Permalink
Browse files

Ensure headers get serialized as raw strings.

Closes #39.
  • Loading branch information...
1 parent 5cdbba3 commit 7ee38dcab23e1b7613f51b51fab1f54e37be5ed6 @myronmarston committed Jan 21, 2011
Showing with 22 additions and 1 deletion.
  1. +8 −1 lib/vcr/structs.rb
  2. +14 −0 spec/vcr/structs_spec.rb
View
@@ -61,7 +61,14 @@ def normalize_headers
important_vals = important_header_values(k, val_array)
next unless important_vals.size > 0
- new_headers[k] = important_vals
+ # Ensure the values are raw strings.
+ # Apparently for Paperclip uploads to S3, headers
+ # get serialized with some extra stuff which leads
+ # to a seg fault. See this issue for more info:
+ # https://github.com/myronmarston/vcr/issues#issue/39
+ string_vals = important_vals.map { |v| String.new(v) }
+
+ new_headers[k] = string_vals
end if headers
self.headers = new_headers.empty? ? nil : new_headers
@@ -23,6 +23,20 @@
it 'sets empty hash header to nil' do
with_headers({}).headers.should be_nil
end
+
+ it 'ensures header keys are serialized to yaml as raw strings' do
+ key = 'my-key'
+ key.instance_variable_set(:@foo, 7)
+ instance = with_headers(key => ['value1'])
+ instance.headers.to_yaml.should == { 'my-key' => ['value1'] }.to_yaml
+ end
+
+ it 'ensures header values are serialized to yaml as raw strings' do
+ value = 'my-value'
+ value.instance_variable_set(:@foo, 7)
+ instance = with_headers('my-key' => [value])
+ instance.headers.to_yaml.should == { 'my-key' => ['my-value'] }.to_yaml
+ end
end
shared_examples_for "a body normalizer" do

0 comments on commit 7ee38dc

Please sign in to comment.