Matthias Brantner has proposed merging lp:~zorba-coders/zorba/trim-http_status 
into lp:zorba.

Commit message:
fix bug causing an untrimmed status message in the result of an http request

Requested reviews:
  Matthias Brantner (matthias-brantner)
  William Candillon (wcandillon)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/trim-http_status/+merge/214314

fix bug causing an untrimmed status message in the result of an http request
-- 
https://code.launchpad.net/~zorba-coders/zorba/trim-http_status/+merge/214314
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'modules/http-client/json/http-client.xq.src/http_response_parser.cpp'
--- modules/http-client/json/http-client.xq.src/http_response_parser.cpp	2014-01-10 15:23:51 +0000
+++ modules/http-client/json/http-client.xq.src/http_response_parser.cpp	2014-04-04 17:28:32 +0000
@@ -30,6 +30,7 @@
 #include <zorba/item.h>
 #include <zorba/item_factory.h>
 #include <zorba/util/transcode_stream.h>
+#include <zorba/zorba_functions.h>
 #include <zorba/xmldatamanager.h>
 #include <zorba/xquery_exception.h>
 #include <zorba/xquery_exception.h>
@@ -286,12 +287,15 @@
 
   void HttpResponseParser::parseStatusAndMessage(std::string const &aHeader)
   {
-    std::string::size_type lPos = aHeader.find(' ');
-    assert(lPos != std::string::npos);
-    std::string lStatus = aHeader.substr(lPos, aHeader.find(' ', lPos + 1));
+    zorba::String lHeader(aHeader);
+    zfn::trim(lHeader);
+    zorba::String::size_type lPos = aHeader.find(' ');
+    assert(lPos != zorba::String::npos);
+    zorba::String lStatus = aHeader.substr(lPos, aHeader.find(' ', lPos + 1));
     theMessage = aHeader.substr(aHeader.find(' ', lPos + 1) + 1);
+
     {
-      std::string::size_type lPosition = theMessage.size() - 1;
+      zorba::String::size_type lPosition = theMessage.size() - 1;
       while (true) {
         if (lPosition != std::string::npos) {
           break;
@@ -304,7 +308,7 @@
       }
       theMessage = theMessage.substr(0, lPosition + 1);
     }
-    std::stringstream lStream(lStatus);
+    std::stringstream lStream(lStatus.c_str());
     lStream >> theStatus;
     // everything that is not a valid http status is an error
     if (theStatus < 100) {

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to