aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files/src/file_provider.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2023-03-22 12:29:58 -0600
committerMarvin W <git@larma.de>2023-03-22 12:35:13 -0600
commit6690d8e4a497eb1f18b43d6147676e08bb298dde (patch)
treea83f5d300f53d1b35d9e3ca3680de6ee689c0ff8 /plugins/http-files/src/file_provider.vala
parentadb2b58b61457df1791ce1ed9b7bb75707d809fb (diff)
downloaddino-6690d8e4a497eb1f18b43d6147676e08bb298dde.tar.gz
dino-6690d8e4a497eb1f18b43d6147676e08bb298dde.zip
Bind soup session lifetime to File provider/sender lifetime
Required since libsoup 3.4. Fixes #1395
Diffstat (limited to 'plugins/http-files/src/file_provider.vala')
-rw-r--r--plugins/http-files/src/file_provider.vala7
1 files changed, 3 insertions, 4 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index 98c1d95c..34c3a48a 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -10,13 +10,16 @@ public class FileProvider : Dino.FileProvider, Object {
private StreamInteractor stream_interactor;
private Dino.Database dino_db;
+ private Soup.Session session;
private static Regex http_url_regex = /^https?:\/\/([^\s#]*)$/; // Spaces are invalid in URLs and we can't use fragments for downloads
private static Regex omemo_url_regex = /^aesgcm:\/\/(.*)#(([A-Fa-f0-9]{2}){48}|([A-Fa-f0-9]{2}){44})$/;
public FileProvider(StreamInteractor stream_interactor, Dino.Database dino_db) {
this.stream_interactor = stream_interactor;
this.dino_db = dino_db;
+ this.session = new Soup.Session();
+ session.user_agent = @"Dino/$(Dino.get_short_version()) ";
stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new ReceivedMessageListener(this));
}
@@ -114,8 +117,6 @@ public class FileProvider : Dino.FileProvider, Object {
HttpFileReceiveData? http_receive_data = receive_data as HttpFileReceiveData;
if (http_receive_data == null) return file_meta;
- var session = new Soup.Session();
- session.user_agent = @"Dino/$(Dino.get_short_version()) ";
var head_message = new Soup.Message("HEAD", http_receive_data.url);
head_message.request_headers.append("Accept-Encoding", "identity");
@@ -150,8 +151,6 @@ public class FileProvider : Dino.FileProvider, Object {
HttpFileReceiveData? http_receive_data = receive_data as HttpFileReceiveData;
if (http_receive_data == null) assert(false);
- var session = new Soup.Session();
- session.user_agent = @"Dino/$(Dino.get_short_version()) ";
var get_message = new Soup.Message("GET", http_receive_data.url);
try {