diff --git a/plugins/backend/bazqux/bazquxConnection.vala b/plugins/backend/bazqux/bazquxConnection.vala index aafc0a3a..a40bd6ff 100644 --- a/plugins/backend/bazqux/bazquxConnection.vala +++ b/plugins/backend/bazqux/bazquxConnection.vala @@ -50,8 +50,8 @@ public class FeedReader.bazquxConnection { var message = new Soup.Message("POST", "https://bazqux.com/accounts/ClientLogin/"); string message_string = "Email=" + m_username + "&Passwd=" + m_passwd; message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data); - m_session.send_and_read(message); - string response = (string)message.response_body.flatten().data; + var response_body = m_session.send_and_read(message); + string response = (string)response_body.get_data(); try{ var regex = new Regex(".*\\w\\s.*\\w\\sAuth="); @@ -100,11 +100,11 @@ public class FeedReader.bazquxConnection { message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data); } - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); return Response() { status = message.status_code, - data = (string)message.response_body.flatten().data + data = (string)response_body.get_data() }; } @@ -114,9 +114,9 @@ public class FeedReader.bazquxConnection { string oldauth = "GoogleLogin auth=" + m_utils.getAccessToken(); message.request_headers.append("Authorization", oldauth); - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); - if((string)message.response_body.data == "OK") + if((string)response_body.get_data() == "OK") { return true; } diff --git a/plugins/backend/feedhq/feedhqConnection.vala b/plugins/backend/feedhq/feedhqConnection.vala index 6ac5c84e..cf2e3c48 100644 --- a/plugins/backend/feedhq/feedhqConnection.vala +++ b/plugins/backend/feedhq/feedhqConnection.vala @@ -50,8 +50,8 @@ public class FeedReader.FeedHQConnection { var message = new Soup.Message("POST", "https://feedhq.org/accounts/ClientLogin"); string message_string = "Email=" + m_username + "&Passwd=" + m_passwd; message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data); - m_session.send_and_read(message); - string response = (string)message.response_body.flatten().data; + var response_body = m_session.send_and_read(message); + string response = (string)response_body.get_data(); try{ var regex = new Regex(".*\\w\\s.*\\w\\sAuth="); @@ -85,7 +85,7 @@ public class FeedReader.FeedHQConnection { string oldauth = "GoogleLogin auth=" + m_utils.getAccessToken(); message.request_headers.append("Authorization", oldauth); - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { @@ -93,7 +93,7 @@ public class FeedReader.FeedHQConnection { return false; } - string response = (string)message.response_body.data; + string response = (string)response_body.get_data(); Logger.debug("FeedHQ post token : " + response); m_utils.setPostToken(response); @@ -124,7 +124,7 @@ public class FeedReader.FeedHQConnection { message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string_post.data); } - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { @@ -140,7 +140,7 @@ public class FeedReader.FeedHQConnection { return Response() { status = message.status_code, - data = (string)message.response_body.flatten().data + data = (string)response_body.get_data() }; } diff --git a/plugins/backend/fresh/freshConnection.vala b/plugins/backend/fresh/freshConnection.vala index 7262e522..2c4a60f0 100644 --- a/plugins/backend/fresh/freshConnection.vala +++ b/plugins/backend/fresh/freshConnection.vala @@ -46,7 +46,7 @@ public class FeedReader.freshConnection { msg.add("Passwd", m_utils.getPasswd()); message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, msg.get().data); - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { @@ -54,7 +54,7 @@ public class FeedReader.freshConnection { return LoginResponse.NO_CONNECTION; } - string response = (string)message.response_body.flatten().data; + string response = (string)response_body.get_data(); if(!response.has_prefix("SID=")) { @@ -92,7 +92,7 @@ public class FeedReader.freshConnection { message.request_headers.append("Content-Type", type); message.request_body.append_take(input.data); - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { @@ -101,7 +101,7 @@ public class FeedReader.freshConnection { return Response() { status = message.status_code, - data = (string)message.response_body.flatten().data + data = (string)response_body.get_data() }; } @@ -115,7 +115,7 @@ public class FeedReader.freshConnection { message.request_headers.append("DNT", "1"); } - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { @@ -124,7 +124,7 @@ public class FeedReader.freshConnection { return Response() { status = message.status_code, - data = (string)message.response_body.flatten().data + data = (string)response_body.get_data() }; } } diff --git a/plugins/backend/inoreader/InoReaderConnection.vala b/plugins/backend/inoreader/InoReaderConnection.vala index 2ac6cd4f..54a15b9d 100644 --- a/plugins/backend/inoreader/InoReaderConnection.vala +++ b/plugins/backend/inoreader/InoReaderConnection.vala @@ -40,14 +40,14 @@ public class FeedReader.InoReaderConnection { + "&scope=" + "&grant_type=authorization_code"; message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data); - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { return LoginResponse.NO_CONNECTION; } - string response = (string)message.response_body.flatten().data; + string response = (string)response_body.get_data(); try { @@ -90,14 +90,14 @@ public class FeedReader.InoReaderConnection { + "&refresh_token=" + m_utils.getRefreshToken(); message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data); - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { return LoginResponse.NO_CONNECTION; } - string response = (string)message.response_body.flatten().data; + string response = (string)response_body.get_data(); try { @@ -156,7 +156,7 @@ public class FeedReader.InoReaderConnection { message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data); } - m_session.send_and_read(message); + var response_body = m_session.send_and_read(message); if(message.status_code != 200) { @@ -166,7 +166,7 @@ public class FeedReader.InoReaderConnection { return Response() { status = message.status_code, - data = (string)message.response_body.flatten().data + data = (string)response_body.get_data().data }; } diff --git a/plugins/backend/local/localInterface.vala b/plugins/backend/local/localInterface.vala index ea9ec8d8..bf9f72a5 100644 --- a/plugins/backend/local/localInterface.vala +++ b/plugins/backend/local/localInterface.vala @@ -529,8 +529,8 @@ public class FeedReader.localInterface : FeedServerInterface { var session = new Soup.Session(); session.user_agent = Constants.USER_AGENT; session.timeout = 5; - session.send_and_read(msg); - string xml = (string)msg.response_body.flatten().data; + var response_body = session.send_and_read(msg); + string xml = (string)response_body.get_data(); // parse Rss.Parser parser = new Rss.Parser(); diff --git a/plugins/backend/local/localUtils.vala b/plugins/backend/local/localUtils.vala index 7901a2d4..ce1062d3 100644 --- a/plugins/backend/local/localUtils.vala +++ b/plugins/backend/local/localUtils.vala @@ -34,7 +34,7 @@ public class FeedReader.localUtils : GLib.Object { return null; } - session.send_and_read(msg); + var response_body = session.send_and_read(msg); uint status = msg.status_code; if(status < 100 || status >= 400) @@ -53,7 +53,7 @@ public class FeedReader.localUtils : GLib.Object { Logger.warning(errmsg); return null; } - string xml = (string)msg.response_body.flatten().data; + string xml = (string)response_body.get_data(); string? url = null; // parse diff --git a/plugins/backend/owncloud/OwncloudNewsMessage.vala b/plugins/backend/owncloud/OwncloudNewsMessage.vala index dcf0d4ad..09bc7d64 100644 --- a/plugins/backend/owncloud/OwncloudNewsMessage.vala +++ b/plugins/backend/owncloud/OwncloudNewsMessage.vala @@ -17,6 +17,7 @@ public class FeedReader.OwnCloudNewsMessage : GLib.Object { private Soup.Session m_session; private Soup.Message m_message_soup; + private Bytes response_body; private GLib.StringBuilder m_message_string; private string m_contenttype; private Json.Parser m_parser; @@ -136,7 +137,7 @@ public class FeedReader.OwnCloudNewsMessage : GLib.Object { m_message_soup.request_headers.append("DNT", "1"); } - m_session.send_and_read(m_message_soup); + response_body = m_session.send_and_read(m_message_soup); var status = m_message_soup.status_code; if(status == 401) // unauthorized @@ -165,7 +166,7 @@ public class FeedReader.OwnCloudNewsMessage : GLib.Object { try { - m_parser.load_from_data((string)m_message_soup.response_body.flatten().data); + m_parser.load_from_data((string)response_body.get_data()); } catch(Error e) { @@ -201,6 +202,6 @@ public class FeedReader.OwnCloudNewsMessage : GLib.Object { public void printResponse() { - Logger.debug((string)m_message_soup.response_body.flatten().data); + Logger.debug((string)response_body.get_data()); } } diff --git a/plugins/backend/ttrss/ttrssMessage.vala b/plugins/backend/ttrss/ttrssMessage.vala index 5e3d71ef..bc5bc74a 100644 --- a/plugins/backend/ttrss/ttrssMessage.vala +++ b/plugins/backend/ttrss/ttrssMessage.vala @@ -17,6 +17,7 @@ public class FeedReader.ttrssMessage : GLib.Object { private Soup.Session m_session; private Soup.Message m_message_soup; + private Bytes response_body; private Json.Object m_request_object = new Json.Object(); private const string m_contenttype = "application/x-www-form-urlencoded"; private Json.Object m_response_object; @@ -97,7 +98,7 @@ public class FeedReader.ttrssMessage : GLib.Object { m_message_soup.request_headers.append("DNT", "1"); } - m_session.send_and_read(m_message_soup); + response_body = m_session.send_and_read(m_message_soup); var status_code = m_message_soup.status_code; if(status_code == 401) // unauthorized @@ -127,7 +128,7 @@ public class FeedReader.ttrssMessage : GLib.Object { var parser = new Json.Parser(); try { - parser.load_from_data((string)m_message_soup.response_body.flatten().data); + parser.load_from_data((string)response_body.get_data()); } catch(Error e) { @@ -220,7 +221,7 @@ public class FeedReader.ttrssMessage : GLib.Object { }); } var request = object_to_string(obj); - var response = (string)m_message_soup.response_body.flatten().data; + var response = (string)response_body.get_data(); Logger.error(@"$prefix\nURL: $url\nRequest object: $request\nResponse: $response"); } diff --git a/plugins/share/Instapaper/InstapaperAPI.vala b/plugins/share/Instapaper/InstapaperAPI.vala index a5974e7f..a61cad01 100644 --- a/plugins/share/Instapaper/InstapaperAPI.vala +++ b/plugins/share/Instapaper/InstapaperAPI.vala @@ -184,8 +184,8 @@ public class FeedReader.InstaAPI : ShareAccountInterface, Peas.ExtensionBase { message_soup.request_headers.append("DNT", "1"); } - session.send_and_read(message_soup); - string response = (string)message_soup.response_body.flatten().data; + var response_body = session.send_and_read(message_soup); + string response = (string)response_body.get_data(); if(response == null || response == "") { diff --git a/plugins/share/Pocket/PocketAPI.vala b/plugins/share/Pocket/PocketAPI.vala index 50ec75dd..52be2a5b 100644 --- a/plugins/share/Pocket/PocketAPI.vala +++ b/plugins/share/Pocket/PocketAPI.vala @@ -78,9 +78,9 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase { message_soup.request_headers.append("DNT", "1"); } - session.send_and_read(message_soup); + var response_body = session.send_and_read(message_soup); - string response = (string)message_soup.response_body.flatten().data; + string response = (string)response_body.get_data(); return response.substring(response.index_of_char('=')+1); } @@ -98,15 +98,15 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase { message_soup.request_headers.append("DNT", "1"); } - session.send_and_read(message_soup); + var response_body = session.send_and_read(message_soup); - if((string)message_soup.response_body.flatten().data == null - || (string)message_soup.response_body.flatten().data == "") + if((string)response_body.get_data() == null + || (string)response_body.get_data() == "") { return false; } - string response = (string)message_soup.response_body.flatten().data; + string response = (string)response_body.get_data(); Logger.debug(response); int tokenStart = response.index_of_char('=')+1; int tokenEnd = response.index_of_char('&', tokenStart); @@ -183,10 +183,10 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase { message_soup.request_headers.append("DNT", "1"); } - session.send_and_read(message_soup); + var response_body = session.send_and_read(message_soup); - if((string)message_soup.response_body.flatten().data == null - || (string)message_soup.response_body.flatten().data == "") + if((string)response_body.get_data() == null + || (string)response_body.get_data() == "") { return false; } diff --git a/plugins/share/Wallabag/WallabagAPI.vala b/plugins/share/Wallabag/WallabagAPI.vala index 56d06956..bf3bc257 100644 --- a/plugins/share/Wallabag/WallabagAPI.vala +++ b/plugins/share/Wallabag/WallabagAPI.vala @@ -40,10 +40,10 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase string url = baseURL + "oauth/v2/token"; var message_soup = new Soup.Message("POST", url); message_soup.set_request("application/x-www-form-urlencoded; charset=UTF8", Soup.MemoryUse.COPY, message.data); - session.send_and_read(message_soup); + var response_body = session.send_and_read(message_soup); - if((string)message_soup.response_body.flatten().data == null - || (string)message_soup.response_body.flatten().data == "") + if((string)response_body.get_data() == null + || (string)response_body.get_data() == "") { Logger.error("WallabagAPI - getAccessToken: no response"); Logger.error(url); @@ -51,7 +51,7 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase return false; } - string response = (string)message_soup.response_body.flatten().data; + string response = (string)response_body.get_data(); Logger.debug(response); var parser = new Json.Parser(); @@ -156,8 +156,8 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase message_soup.request_headers.append("Authorization", "Bearer " + settings.get_string("oauth-access-token")); session.send_and_read(message_soup); - if((string)message_soup.response_body.flatten().data == null - || (string)message_soup.response_body.flatten().data == "") + if((string)response_body.get_data() == null + || (string)response_body.get_data() == "") { Logger.error("WallabagAPI - addBookmark: no response"); Logger.error(url); diff --git a/src/ContentGrabber/grabber.vala b/src/ContentGrabber/grabber.vala index 57dc974d..594dd147 100644 --- a/src/ContentGrabber/grabber.vala +++ b/src/ContentGrabber/grabber.vala @@ -245,22 +245,22 @@ public class FeedReader.Grabber : GLib.Object { msg.request_headers.append("DNT", "1"); } - m_session.send_and_read(msg); + var response_body = m_session.send_and_read(msg); msg.disconnect(handlerID); - if(msg.response_body == null) + if(response_body == null) { Logger.debug("Grabber: download failed - no response"); return false; } - if((string)msg.response_body.flatten().data == "") + if((string)response_body.get_data() == "") { Logger.debug("Grabber: download failed - empty response"); return false; } - m_rawHtml = (string)msg.response_body.flatten().data; + m_rawHtml = (string)response_body.get_data(); if(!m_rawHtml.validate()) { string needle = "content=\"text/html; charset="; diff --git a/src/ContentGrabber/grabberUtils.vala b/src/ContentGrabber/grabberUtils.vala index dc57cc6c..2387a56a 100644 --- a/src/ContentGrabber/grabberUtils.vala +++ b/src/ContentGrabber/grabberUtils.vala @@ -630,7 +630,7 @@ public class FeedReader.grabberUtils : GLib.Object { message_dlImg.request_headers.append("DNT", "1"); } - session.send_and_read(message_dlImg); + var response_body = session.send_and_read(message_dlImg); var status = message_dlImg.status_code; if(status == 200) @@ -648,8 +648,8 @@ public class FeedReader.grabberUtils : GLib.Object { try{ FileUtils.set_contents( localFilename, - (string)message_dlImg.response_body.flatten().data, - (long)message_dlImg.response_body.length); + (string)response_body.get_data(), + (long)response_body.length); } catch(GLib.FileError e) {