diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-05-01 14:43:08 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-05-01 14:43:08 +0200 |
commit | 2b3f22361da0c1d8e6ce70d71352821758186db7 (patch) | |
tree | 5d10633b47369b3aa52a05bf889ede0dbe5ee108 /plugins/common/RESTSupport.vala | |
parent | 211da5fc3048ca2b6ccee2166b0aaaade55cb84f (diff) | |
parent | dc6c76eb04dfe3d4262a1806808f0bc0bf523238 (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'plugins/common/RESTSupport.vala')
-rw-r--r-- | plugins/common/RESTSupport.vala | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala index f06473c..d92c264 100644 --- a/plugins/common/RESTSupport.vala +++ b/plugins/common/RESTSupport.vala @@ -123,6 +123,20 @@ public class Argument { this.value = value; } + public static string serialize_list(Argument[] args, bool escape = false, string? separator = "&") { + var builder = new StringBuilder(""); + + foreach (var arg in args) { + builder.append(arg.to_string(escape)); + builder.append(separator); + } + + if (builder.len > 0) + builder.truncate(builder.len - separator.length); + + return builder.str; + } + public static int compare(Argument arg1, Argument arg2) { return strcmp(arg1.key, arg2.key); } @@ -136,8 +150,8 @@ public class Argument { return sorted_args.to_array(); } - public string to_string () { - return "%s=%s".printf (this.key, this.value); + public string to_string (bool escape = false) { + return "%s=%s%s%s".printf (this.key, escape ? "\"" : "", this.value, escape ? "\"" : ""); } } @@ -154,6 +168,7 @@ public class Transaction { public signal void chunk_transmitted(int bytes_written_so_far, int total_bytes); public signal void network_error(Spit.Publishing.PublishingError err); public signal void completed(); + public Transaction(Session parent_session, HttpMethod method = HttpMethod.POST) { // if our creator doesn't specify an endpoint url by using the Transaction.with_endpoint_url |