diff options
Diffstat (limited to 'plugins/http-files')
-rw-r--r-- | plugins/http-files/src/file_provider.vala | 8 | ||||
-rw-r--r-- | plugins/http-files/src/upload_stream_module.vala | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala index 9e677a92..53fe3bb0 100644 --- a/plugins/http-files/src/file_provider.vala +++ b/plugins/http-files/src/file_provider.vala @@ -48,8 +48,13 @@ public class FileProvider : Dino.FileProvider, Object { if (name == "Content-Length") content_length = val; }); if (/*content_type != null && content_type.has_prefix("image") &&*/ content_length != null && int.parse(content_length) < 5000000) { - Soup.Request request = session.request (message.body); FileTransfer file_transfer = new FileTransfer(); + try { + Soup.Request request = session.request(message.body); + file_transfer.input_stream = request.send(); + } catch (Error e) { + return; + } file_transfer.account = conversation.account; file_transfer.counterpart = message.counterpart; file_transfer.ourpart = message.ourpart; @@ -57,7 +62,6 @@ public class FileProvider : Dino.FileProvider, Object { file_transfer.time = message.time; file_transfer.local_time = message.local_time; file_transfer.direction = message.direction; - file_transfer.input_stream = request.send(); file_transfer.file_name = message.body.substring(message.body.last_index_of("/") + 1); file_transfer.mime_type = content_type; file_transfer.size = int.parse(content_length); diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala index ee70e49d..08e6105f 100644 --- a/plugins/http-files/src/upload_stream_module.vala +++ b/plugins/http-files/src/upload_stream_module.vala @@ -21,7 +21,11 @@ public class UploadStreamModule : XmppStreamModule { Array<uint8> data = new Array<uint8>(false, true, 0); size_t len = -1; do { - len = input_stream.read(buf); + try { + len = input_stream.read(buf); + } catch (IOError error) { + error_listener(stream, @"HTTP upload: IOError reading stream: $(error.message)"); + } data.append_vals(buf, (uint) len); } while(len > 0); @@ -41,7 +45,7 @@ public class UploadStreamModule : XmppStreamModule { } }); }, - error_listener); + (stream, error) => error_listener(stream, error)); } private delegate void OnSlotOk(XmppStream stream, string url_get, string url_put); |