diff options
author | Wiktor Kwapisiewicz <wiktor@metacode.biz> | 2019-11-06 13:10:32 +0100 |
---|---|---|
committer | fiaxh <fiaxh@users.noreply.github.com> | 2019-11-19 21:24:28 +0100 |
commit | 687ec1a15969a88e00f84b6f45f751c99cc91d92 (patch) | |
tree | f48e2fca3be2723abb89e97000ece96e04a565b4 /plugins/http-files | |
parent | e6918b35b382c3365b220582a32c97ec25037cc8 (diff) | |
download | dino-687ec1a15969a88e00f84b6f45f751c99cc91d92.tar.gz dino-687ec1a15969a88e00f84b6f45f751c99cc91d92.zip |
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
Diffstat (limited to 'plugins/http-files')
-rw-r--r-- | plugins/http-files/src/file_sender.vala | 4 |
1 files changed, 4 insertions, 0 deletions
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)); |