[shotwell] piwigo: Let libsoup do the cookie parsing
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] piwigo: Let libsoup do the cookie parsing
- Date: Sun, 12 Jun 2016 07:29:05 +0000 (UTC)
commit be9c9303d9307ae1724d7396bcbd31ae3fe4e1b4
Author: Jens Georg <mail jensge org>
Date: Fri Jun 10 00:18:58 2016 +0200
piwigo: Let libsoup do the cookie parsing
Signed-off-by: Jens Georg <mail jensge org>
plugins/common/RESTSupport.vala | 5 +++
plugins/shotwell-publishing/PiwigoPublishing.vala | 31 +++++++--------------
2 files changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 08e4e15..b19d723 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -352,6 +352,11 @@ public class Transaction {
assert(get_is_executed());
return message.response_headers;
}
+
+ public Soup.Message get_message() {
+ assert(get_is_executed());
+ return message;
+ }
public void add_argument(string name, string value) {
arguments += new Argument(name, value);
diff --git a/plugins/shotwell-publishing/PiwigoPublishing.vala
b/plugins/shotwell-publishing/PiwigoPublishing.vala
index d7b972b..ff8ad1f 100644
--- a/plugins/shotwell-publishing/PiwigoPublishing.vala
+++ b/plugins/shotwell-publishing/PiwigoPublishing.vala
@@ -937,29 +937,18 @@ public class PiwigoPublisher : Spit.Publishing.Publisher, GLib.Object {
* @param txn the received transaction
* @return the value of pwg_id if present or null if not found
*/
- private new string? get_pwg_id_from_transaction(Publishing.RESTSupport.Transaction txn) {
- string cookie = txn.get_response_headers().get_list("Set-Cookie");
- string pwg_id = null;
- debug("Full cookie string: %s".printf(cookie));
- if (!is_string_empty(cookie)) {
- string[] cookie_segments = cookie.split(";");
- debug("Split full string into %d individual segments".printf(cookie_segments.length));
- foreach(string cookie_segment in cookie_segments) {
- debug("Individual cookie segment: %s".printf(cookie_segment));
- string[] cookie_sub_segments = cookie_segment.split(",");
- debug("Split segment into %d individual sub-segments".printf(cookie_sub_segments.length));
- foreach(string cookie_sub_segment in cookie_sub_segments) {
- debug("Individual cookie sub-segment: %s".printf(cookie_sub_segment));
- string[] cookie_kv = cookie_sub_segment.split("=");
- debug("Split sub-segment into %d chunks".printf(cookie_kv.length));
- if (cookie_kv.length > 1 && cookie_kv[0].strip() == "pwg_id") {
- debug("Found pwg_id: %s".printf(cookie_kv[1].strip()));
- pwg_id = cookie_kv[1].strip();
- }
- }
+ private string? get_pwg_id_from_transaction(Publishing.RESTSupport.Transaction txn) {
+ string? pwg_id = null;
+
+ foreach (var cookie in Soup.cookies_from_response(txn.get_message())) {
+ if (cookie.get_name() == "pwg_id") {
+ // Collect all ids, last one is the one to use. First one is
+ // for Guest apparently
+ pwg_id = cookie.get_value();
+ debug ("Found pwg_id %s", pwg_id);
}
}
-
+
return pwg_id;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]