diff options
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 |