aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files/src/upload_stream_module.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-08-30 00:03:37 +0200
committerfiaxh <git@mx.ax.lt>2017-08-31 18:54:38 +0200
commita257b163376174e4f5efcbc82c9fdd56463c3191 (patch)
tree5aedafe95426e732d4b4790edc4e23de25844e5d /plugins/http-files/src/upload_stream_module.vala
parent9b5bd0ccf0cdeb49f900450df8eea41c6a0dea75 (diff)
downloaddino-a257b163376174e4f5efcbc82c9fdd56463c3191.tar.gz
dino-a257b163376174e4f5efcbc82c9fdd56463c3191.zip
Download & inline display images
Diffstat (limited to 'plugins/http-files/src/upload_stream_module.vala')
-rw-r--r--plugins/http-files/src/upload_stream_module.vala15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala
index 2e697afa..2e794593 100644
--- a/plugins/http-files/src/upload_stream_module.vala
+++ b/plugins/http-files/src/upload_stream_module.vala
@@ -25,9 +25,18 @@ public class UploadStreamModule : XmppStreamModule {
Soup.Message message = new Soup.Message("PUT", url_up);
message.set_request(file_info.get_content_type(), Soup.MemoryUse.COPY, data);
Soup.Session session = new Soup.Session();
- session.send_async(message);
-
- listener(stream, url_down);
+ session.send_async.begin(message, null, (obj, res) => {
+ try {
+ session.send_async.end(res);
+ if (message.status_code == 200) {
+ listener(stream, url_down);
+ } else {
+ error_listener(stream, "HTTP status code " + message.status_code.to_string());
+ }
+ } catch (Error e) {
+ error_listener(stream, e.message);
+ }
+ });
},
error_listener);
}