From 687ec1a15969a88e00f84b6f45f751c99cc91d92 Mon Sep 17 00:00:00 2001 From: Wiktor Kwapisiewicz Date: Wed, 6 Nov 2019 13:10:32 +0100 Subject: Add support for HTTP Upload headers Some services use Authorization header [0] to pass upload credential data. This avoids the token being exposed in server logs and is allowed by XEP-0363 since version 0.5.0. This change adds support for headers allowed in XEP-0363: Authorization, Expires and Cookie. [0]: https://xmpp.org/extensions/xep-0363.html#request --- plugins/http-files/src/file_sender.vala | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/http-files') diff --git a/plugins/http-files/src/file_sender.vala b/plugins/http-files/src/file_sender.vala index 41829dd9..3d250c1f 100644 --- a/plugins/http-files/src/file_sender.vala +++ b/plugins/http-files/src/file_sender.vala @@ -28,6 +28,7 @@ public class HttpFileSender : FileSender, Object { var slot_result = yield stream_interactor.module_manager.get_module(file_transfer.account, Xmpp.Xep.HttpFileUpload.Module.IDENTITY).request_slot(stream, file_transfer.server_file_name, file_meta.size, file_meta.mime_type); send_data.url_down = slot_result.url_get; send_data.url_up = slot_result.url_put; + send_data.headers = slot_result.headers; } catch (Xep.HttpFileUpload.HttpFileTransferError e) { throw new FileSendError.UPLOAD_FAILED("Http file upload XMPP error: %s".printf(e.message)); } @@ -96,6 +97,9 @@ public class HttpFileSender : FileSender, Object { Soup.Message message = new Soup.Message("PUT", file_send_data.url_up); message.request_headers.set_content_type(file_meta.mime_type, null); message.request_headers.set_content_length(file_meta.size); + foreach (var entry in file_send_data.headers.entries) { + message.request_headers.append(entry.key, entry.value); + } message.request_body.set_accumulate(false); message.wrote_headers.connect(() => transfer_more_bytes(file_transfer.input_stream, message.request_body)); message.wrote_chunk.connect(() => transfer_more_bytes(file_transfer.input_stream, message.request_body)); -- cgit v1.2.3-70-g09d2