Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Response Body not rewound with get_object with a version_id #67

@NZKoz

Description

@NZKoz

when I retrieve a versioned object from s3, the PlainStringIO is at the end of the file. So the code I have to write is:

      object = @s3.get_object(bucket:@s3_bucket, key: key, version_id: version)
      # TODO find out why this isn't always rewound?
      object.body.rewind if object.body.respond_to?(:rewind)
      Yajl::Parser.parse(object.body)

If I don't rewind the bodies, #read returns an empty string and there's a parsing error.

Looking at response.rb in seahorse I see that body= doesn't rewind or otherwise sanity check IOs it receives:

        def body=(io)
          @body = case io
            when nil then PlainStringIO.new('')
            when String then PlainStringIO.new(io)
            else io
          end
        end

However I can't follow where the response bodies are actually set, so unfortunately I can't see if all those paths are ensuring that the values they set are in a sane state. By default they wouldn't be:

s = StringIO.new # => #<StringIO:0x007fdd722680c0>
s.write("asdf") # => 4
s.read # => ""

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions