GNOME Bugzilla – Bug 605862
libsoup scrambles binary data
Last modified: 2010-01-25 09:09:24 UTC
It seems libsoup doesn't handle binary files like images and such. I asked on the libsoup mailing list and was suggested it was a Vala implementation problem (http://markmail.org/message/miwspdv5oknzq3ct) This example program given an image of 4 bytes when it's actually 444 k. =============================================================================== //! download-binary.vala //! //! compile: //! valac -o test --pkg libsoup-2.4 --pkg gio-2.0 --thread download-binary.vala int main(string[] args) { var url = "http://www.poppa.se/blog/data/images/gnome-shield-4.jpg"; var sess = new Soup.SessionSync(); var mess = new Soup.Message("GET", url); sess.add_feature = new Soup.Logger(Soup.LoggerLogLevel.HEADERS, -1); sess.send_message(mess); file_put_contents(Path.get_basename(url), mess.response_body.data); return 0; } void file_put_contents(string file, string contents) { try { var f = File.new_for_path(file); if (f.query_exists(null)) f.delete(null); var fs = f.create(FileCreateFlags.NONE, null); if (!f.query_exists(null)) { warning("Unable to create file \"%s\"!", file); return; } var ds = new DataOutputStream(fs); ds.put_string(contents, null); } catch (Error e) { warning("Error writing file: %s", e.message); } } =============================================================================== I apologize if this actually is not a bug but rather a mis-usage from my side.
That's definitely a bindings bug (could you change the component?). MessageBody#data should be uint8[] rather than a string.
I changed the "component" to "Bindings". Thank you.
commit 6ffe00e3fa8e1cad4e965d087ab1a9c312e1bd8f Author: Evan Nemerson <evan@coeus-group.com> Date: Mon Jan 25 01:07:03 2010 -0800 libsoup-2.4: SoupMessageBody.data should be uing8[], not string. Fixes bug 605862.