summaryrefslogtreecommitdiff
path: root/plugins/common/RESTSupport.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-07-09 12:10:38 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-07-09 12:10:38 +0200
commit709e2d6f5652ec90c194a4ec2b530bebc6f952cb (patch)
tree496b2f3899e1d5728ee9ae76095cc5056c317447 /plugins/common/RESTSupport.vala
parentf1353e9ffd34db5f755c7da0b3f9c10638fbfd38 (diff)
parent5c8be07095cc04a6d8a95204b0504fd7ab030154 (diff)
Merge branch 'release/0.28.3-1'0.28.3-1
Diffstat (limited to 'plugins/common/RESTSupport.vala')
-rw-r--r--plugins/common/RESTSupport.vala19
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