Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix framing issue in the encode_body() method #34

Merged
merged 1 commit into from Sep 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/amq/protocol/client.rb
Expand Up @@ -177,7 +177,7 @@ def self.encode_body(body, channel, frame_size)
body.force_encoding("ASCII-8BIT") if RUBY_VERSION.to_f >= 1.9

array = Array.new
while body
while body && !body.empty?
payload, body = body[0, limit], body[limit, body.length - limit]
array << BodyFrame.new(payload, channel)
end
Expand Down
8 changes: 8 additions & 0 deletions spec/amq/protocol/method_spec.rb
Expand Up @@ -34,6 +34,14 @@ module Protocol
body_frames.map(&:payload).should == lipsum.split('').each_slice(expected_payload_size).map(&:join)
end
end

context 'when the body fits perfectly in a single frame' do
it 'encodes a body into a single BodyFrame' do
body_frames = Method.encode_body('*' * 131064, 1, 131072)
body_frames.first.payload.should == '*' * 131064
body_frames.should have(1).item
end
end
end
end
end
Expand Down