diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-13 10:04:38 -0400 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-13 10:04:38 -0400 |
commit | 98bfa93ef9a9383a6c0585a081178bb45f6a4097 (patch) | |
tree | 6189dbed1e570ce03b91683838cb3d97e257e2b9 | |
parent | d2cfd8203e0108db3b49d10a7ca3990f49667a9e (diff) |
read chunks
-rw-r--r-- | lib/freeswitch_event.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/freeswitch_event.rb b/lib/freeswitch_event.rb index 6745bef..5f961be 100644 --- a/lib/freeswitch_event.rb +++ b/lib/freeswitch_event.rb @@ -129,8 +129,12 @@ class FreeswitchAPI event.command("api #{command} #{arguments.join(' ')}") result = event.result() content_length = result['Content-Length'].to_i - if content_length > 0 && result['_BODY'].blank? - result['_BODY'] = event.read(content_length); + while content_length > result['_BODY'].to_s.length + body = event.read(content_length - result['_BODY'].to_s.length) + if body.blank? + break + end + result['_BODY'] = result['_BODY'].to_s + body; end event.close() return result |