[jira] [Commented] (PROTON-736) ruby: unable to send binary data?
[ https://issues.apache.org/jira/browse/PROTON-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14231674#comment-14231674 ] ASF subversion and git services commented on PROTON-736: Commit e6c6873af7b83699ac94d8fe699beb51d1e2ef9d in qpid-proton's branch refs/heads/master from [~mcpierce] [ https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;h=e6c6873 ] PROTON-736: Tweaked how Ruby 1.8 determines if a string is UTF-8 Uses the kconv stdlib module to add the isutf8 method. ruby: unable to send binary data? - Key: PROTON-736 URL: https://issues.apache.org/jira/browse/PROTON-736 Project: Qpid Proton Issue Type: Bug Components: ruby-binding Affects Versions: 0.8 Reporter: Dominic Evans Assignee: Darryl L. Pierce Fix For: 0.9 Attachments: 0001-PROTON-736-Created-the-UTFString-and-BinaryString-cl.patch, 0001-PROTON-736-Default-Ruby-1.8-encoding-to-be-binary-un.patch, 0001-PROTON-736-Ruby-Message-does-not-return-all-content.patch, 0002-PROTON-736-Only-encode-Ruby-strings-as-UTF-8-if-it-s.patch As discussed on irc with [~mcpierce] I've not been able to determine how I can correctly send binary data using the ruby gem. From proton-c I can do this by (e.g.,) {{ char* msgdata = Buffer::Data(buffer); size_t msglen = Buffer::Length(buffer); pn_message_set_format(msg-message, PN_DATA); pn_message_load_data(msg-message, msgdata, msglen); }} and I assumed I might be able to do similar from Ruby by (e.g.,) {{ data = File.binread(filename) msg.format = Qpid::Proton::MessageFormat::DATA msg.content = data }} But Ruby is reading the data into a string and the SWIG binding is still expecting a byte* array here. After our discussions on IRC I also investigated doing: {{ filedata = File.binread(filename) data = Qpid::Proton::Data.new data.binary = filedata msg.body = data }} but didn't have any luck with this approach either. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PROTON-736) ruby: unable to send binary data?
[ https://issues.apache.org/jira/browse/PROTON-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14216195#comment-14216195 ] ASF subversion and git services commented on PROTON-736: Commit d770a1ef689d859888f8cc610486b0dba4ea5fa9 in qpid-proton's branch refs/heads/master from [~mcpierce] [ https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;h=d770a1e ] PROTON-736: Replace missed force_encoding with encode ruby: unable to send binary data? - Key: PROTON-736 URL: https://issues.apache.org/jira/browse/PROTON-736 Project: Qpid Proton Issue Type: Bug Components: ruby-binding Affects Versions: 0.8 Reporter: Dominic Evans Assignee: Darryl L. Pierce Fix For: 0.9 Attachments: 0001-PROTON-736-Created-the-UTFString-and-BinaryString-cl.patch, 0001-PROTON-736-Default-Ruby-1.8-encoding-to-be-binary-un.patch, 0001-PROTON-736-Ruby-Message-does-not-return-all-content.patch, 0002-PROTON-736-Only-encode-Ruby-strings-as-UTF-8-if-it-s.patch As discussed on irc with [~mcpierce] I've not been able to determine how I can correctly send binary data using the ruby gem. From proton-c I can do this by (e.g.,) {{ char* msgdata = Buffer::Data(buffer); size_t msglen = Buffer::Length(buffer); pn_message_set_format(msg-message, PN_DATA); pn_message_load_data(msg-message, msgdata, msglen); }} and I assumed I might be able to do similar from Ruby by (e.g.,) {{ data = File.binread(filename) msg.format = Qpid::Proton::MessageFormat::DATA msg.content = data }} But Ruby is reading the data into a string and the SWIG binding is still expecting a byte* array here. After our discussions on IRC I also investigated doing: {{ filedata = File.binread(filename) data = Qpid::Proton::Data.new data.binary = filedata msg.body = data }} but didn't have any luck with this approach either. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PROTON-736) ruby: unable to send binary data?
[ https://issues.apache.org/jira/browse/PROTON-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14212119#comment-14212119 ] ASF subversion and git services commented on PROTON-736: Commit cccd05067d45623e3690945ebe4cda764c96e955 in qpid-proton's branch refs/heads/examples from [~mcpierce] [ https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;h=cccd050 ] PROTON-736: Default Ruby 1.8 encoding to be binary unless explicit Also updated the patch to not re-encode the original string while checking its value. ruby: unable to send binary data? - Key: PROTON-736 URL: https://issues.apache.org/jira/browse/PROTON-736 Project: Qpid Proton Issue Type: Bug Components: ruby-binding Affects Versions: 0.8 Reporter: Dominic Evans Assignee: Darryl L. Pierce Fix For: 0.9 Attachments: 0001-PROTON-736-Created-the-UTFString-and-BinaryString-cl.patch, 0001-PROTON-736-Default-Ruby-1.8-encoding-to-be-binary-un.patch, 0001-PROTON-736-Ruby-Message-does-not-return-all-content.patch, 0002-PROTON-736-Only-encode-Ruby-strings-as-UTF-8-if-it-s.patch As discussed on irc with [~mcpierce] I've not been able to determine how I can correctly send binary data using the ruby gem. From proton-c I can do this by (e.g.,) {{ char* msgdata = Buffer::Data(buffer); size_t msglen = Buffer::Length(buffer); pn_message_set_format(msg-message, PN_DATA); pn_message_load_data(msg-message, msgdata, msglen); }} and I assumed I might be able to do similar from Ruby by (e.g.,) {{ data = File.binread(filename) msg.format = Qpid::Proton::MessageFormat::DATA msg.content = data }} But Ruby is reading the data into a string and the SWIG binding is still expecting a byte* array here. After our discussions on IRC I also investigated doing: {{ filedata = File.binread(filename) data = Qpid::Proton::Data.new data.binary = filedata msg.body = data }} but didn't have any luck with this approach either. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PROTON-736) ruby: unable to send binary data?
[ https://issues.apache.org/jira/browse/PROTON-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14208251#comment-14208251 ] ASF subversion and git services commented on PROTON-736: Commit cccd05067d45623e3690945ebe4cda764c96e955 in qpid-proton's branch refs/heads/master from [~mcpierce] [ https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;h=cccd050 ] PROTON-736: Default Ruby 1.8 encoding to be binary unless explicit Also updated the patch to not re-encode the original string while checking its value. ruby: unable to send binary data? - Key: PROTON-736 URL: https://issues.apache.org/jira/browse/PROTON-736 Project: Qpid Proton Issue Type: Bug Components: ruby-binding Affects Versions: 0.8 Reporter: Dominic Evans Assignee: Darryl L. Pierce Fix For: 0.9 Attachments: 0001-PROTON-736-Created-the-UTFString-and-BinaryString-cl.patch, 0001-PROTON-736-Default-Ruby-1.8-encoding-to-be-binary-un.patch, 0001-PROTON-736-Ruby-Message-does-not-return-all-content.patch, 0002-PROTON-736-Only-encode-Ruby-strings-as-UTF-8-if-it-s.patch As discussed on irc with [~mcpierce] I've not been able to determine how I can correctly send binary data using the ruby gem. From proton-c I can do this by (e.g.,) {{ char* msgdata = Buffer::Data(buffer); size_t msglen = Buffer::Length(buffer); pn_message_set_format(msg-message, PN_DATA); pn_message_load_data(msg-message, msgdata, msglen); }} and I assumed I might be able to do similar from Ruby by (e.g.,) {{ data = File.binread(filename) msg.format = Qpid::Proton::MessageFormat::DATA msg.content = data }} But Ruby is reading the data into a string and the SWIG binding is still expecting a byte* array here. After our discussions on IRC I also investigated doing: {{ filedata = File.binread(filename) data = Qpid::Proton::Data.new data.binary = filedata msg.body = data }} but didn't have any luck with this approach either. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PROTON-736) ruby: unable to send binary data?
[ https://issues.apache.org/jira/browse/PROTON-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14204953#comment-14204953 ] Darryl L. Pierce commented on PROTON-736: - Attached is an update that hopefully settles those issues by letting the user explicitly state if a string is UTF-8 or binary data in Ruby. It adds two classes, Qpid::Proton::UTFString and Qpid::Proton::BinaryString, that thinly wrap the standard String class. ruby: unable to send binary data? - Key: PROTON-736 URL: https://issues.apache.org/jira/browse/PROTON-736 Project: Qpid Proton Issue Type: Bug Components: ruby-binding Affects Versions: 0.8 Reporter: Dominic Evans Assignee: Darryl L. Pierce Fix For: 0.9 Attachments: 0001-PROTON-736-Created-the-UTFString-and-BinaryString-cl.patch, 0001-PROTON-736-Ruby-Message-does-not-return-all-content.patch, 0002-PROTON-736-Only-encode-Ruby-strings-as-UTF-8-if-it-s.patch As discussed on irc with [~mcpierce] I've not been able to determine how I can correctly send binary data using the ruby gem. From proton-c I can do this by (e.g.,) {{ char* msgdata = Buffer::Data(buffer); size_t msglen = Buffer::Length(buffer); pn_message_set_format(msg-message, PN_DATA); pn_message_load_data(msg-message, msgdata, msglen); }} and I assumed I might be able to do similar from Ruby by (e.g.,) {{ data = File.binread(filename) msg.format = Qpid::Proton::MessageFormat::DATA msg.content = data }} But Ruby is reading the data into a string and the SWIG binding is still expecting a byte* array here. After our discussions on IRC I also investigated doing: {{ filedata = File.binread(filename) data = Qpid::Proton::Data.new data.binary = filedata msg.body = data }} but didn't have any luck with this approach either. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PROTON-736) ruby: unable to send binary data?
[ https://issues.apache.org/jira/browse/PROTON-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14205343#comment-14205343 ] ASF subversion and git services commented on PROTON-736: Commit 6371e9eba3b82a4927bcfb06919d4b3ea419a8d8 in qpid-proton's branch refs/heads/master from [~mcpierce] [ https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;h=6371e9e ] PROTON-736: Created the UTFString and BinaryString classes for Ruby. This allows users to explictly call out that a string is either UTF-8 or a binary string. For the UTFString type, it validates that the content provided is actually UTF-8 and raises a RuntimeError if it's not. Results returned from a Message object are wrapped in the appropriate class. This solution is Ruby 1.8, 1.9 and 2.0 compatible. ruby: unable to send binary data? - Key: PROTON-736 URL: https://issues.apache.org/jira/browse/PROTON-736 Project: Qpid Proton Issue Type: Bug Components: ruby-binding Affects Versions: 0.8 Reporter: Dominic Evans Assignee: Darryl L. Pierce Fix For: 0.9 Attachments: 0001-PROTON-736-Created-the-UTFString-and-BinaryString-cl.patch, 0001-PROTON-736-Ruby-Message-does-not-return-all-content.patch, 0002-PROTON-736-Only-encode-Ruby-strings-as-UTF-8-if-it-s.patch As discussed on irc with [~mcpierce] I've not been able to determine how I can correctly send binary data using the ruby gem. From proton-c I can do this by (e.g.,) {{ char* msgdata = Buffer::Data(buffer); size_t msglen = Buffer::Length(buffer); pn_message_set_format(msg-message, PN_DATA); pn_message_load_data(msg-message, msgdata, msglen); }} and I assumed I might be able to do similar from Ruby by (e.g.,) {{ data = File.binread(filename) msg.format = Qpid::Proton::MessageFormat::DATA msg.content = data }} But Ruby is reading the data into a string and the SWIG binding is still expecting a byte* array here. After our discussions on IRC I also investigated doing: {{ filedata = File.binread(filename) data = Qpid::Proton::Data.new data.binary = filedata msg.body = data }} but didn't have any luck with this approach either. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PROTON-736) ruby: unable to send binary data?
[ https://issues.apache.org/jira/browse/PROTON-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14196358#comment-14196358 ] Dominic Evans commented on PROTON-736: -- [~mcpierce] as discussed on IRC The problem here is that ruby doesn't really differentiate between Binary data and (utf-8) String data. The IO.binread [1] method just reads that data into a string primitive and marks it as rb:ASCII-8BIT to prevent any encoding/decoding or line-ending changes from taking place on it. This can be seen in the mapping.rb code by the fact that the AMQP Binary type has klasses=nil for Ruby. As such, if you use the message.body= setter and give it a String, you will always end up with the message body being encoded as an AmqpValue containing a String type. However, this is actually a spec-incompliant behaviour, because the spec states that a String type will only contain UTF-8 encoded data. Hence, if you try to receive that message using either a proton-j or python client the String will fail to decode. Its not obvious what the correct fix here would be, but I'd suggest something along the lines of: 1) raise an exception in msg.body= if you pass a string primitive that doesn't contain valid UTF-8 2) add the ability in message.rb to set your own arbitary Qpid::Proton::Data object as the message body and map to and from that rather than ruby primitives if it has been used -- [1] http://ruby-doc.org/core-1.9.2/IO.html#method-c-binread ruby: unable to send binary data? - Key: PROTON-736 URL: https://issues.apache.org/jira/browse/PROTON-736 Project: Qpid Proton Issue Type: Bug Components: ruby-binding Affects Versions: 0.8 Reporter: Dominic Evans Assignee: Darryl L. Pierce Attachments: 0001-PROTON-736-Ruby-Message-does-not-return-all-content.patch As discussed on irc with [~mcpierce] I've not been able to determine how I can correctly send binary data using the ruby gem. From proton-c I can do this by (e.g.,) {{ char* msgdata = Buffer::Data(buffer); size_t msglen = Buffer::Length(buffer); pn_message_set_format(msg-message, PN_DATA); pn_message_load_data(msg-message, msgdata, msglen); }} and I assumed I might be able to do similar from Ruby by (e.g.,) {{ data = File.binread(filename) msg.format = Qpid::Proton::MessageFormat::DATA msg.content = data }} But Ruby is reading the data into a string and the SWIG binding is still expecting a byte* array here. After our discussions on IRC I also investigated doing: {{ filedata = File.binread(filename) data = Qpid::Proton::Data.new data.binary = filedata msg.body = data }} but didn't have any luck with this approach either. -- This message was sent by Atlassian JIRA (v6.3.4#6332)