[Libreoffice-commits] online.git: Branch 'private/Ashod/nonblocking' - net/clientnb.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sat Feb 18 21:17:35 UTC 2017


 net/clientnb.cpp |   24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

New commits:
commit fe1fce20cb813a59771e7ffad11e0b77c861bde9
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Feb 18 14:49:46 2017 -0500

    nb: refactor getResponse into raw string and int versions
    
    Change-Id: I77d8085cc811c7caf4434af823e62fd1333090f1
    Reviewed-on: https://gerrit.libreoffice.org/34412
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/net/clientnb.cpp b/net/clientnb.cpp
index 9877d66..7aadaa1 100644
--- a/net/clientnb.cpp
+++ b/net/clientnb.cpp
@@ -91,17 +91,23 @@ struct Session
             throw;
         }
     }
-    int getResponse()
+
+    std::string getResponseString()
     {
-        int number = 42;
         Poco::Net::HTTPResponse response;
+        std::istream& responseStream = _session->receiveResponse(response);
+        const std::string result(std::istreambuf_iterator<char>(responseStream), {});
+        // std::cerr << "Got response '" << result << "'\n";
+        return result;
+    }
+
+    int getResponseInt()
+    {
+        int number = 42;
 
         try {
 //            std::cerr << "try to get response\n";
-            std::istream& responseStream = _session->receiveResponse(response);
-
-            std::string result(std::istreambuf_iterator<char>(responseStream), {});
-//            std::cerr << "Got response '" << result << "'\n";
+            const std::string result = getResponseString();
             number = std::stoi(result);
         }
         catch (const Poco::Exception &e)
@@ -136,7 +142,7 @@ struct ThreadWorker : public Runnable
         {
             Session ping(_domain ? _domain : "init", EnableHttps);
             ping.sendPing(i);
-            int back = ping.getResponse();
+            int back = ping.getResponseInt();
             assert(back == i + 1);
         }
     }
@@ -154,11 +160,11 @@ struct Client : public Poco::Util::Application
         first.sendPing(count);
         second.sendPing(count + 1);
 
-        back = first.getResponse();
+        back = first.getResponseInt();
         std::cerr << "testPing: " << back << "\n";
         assert (back == count + 1);
 
-        back = second.getResponse();
+        back = second.getResponseInt();
         std::cerr << "testPing: " << back << "\n";
         assert (back == count + 2);
     }


More information about the Libreoffice-commits mailing list