You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a problem with HTTPClientSession.receiveResponse since switching to gcc 4.8 using c++11 flags (on maxOsX lion).
I have some simple code that is supposed to connect to a basic http server which responds with a JSON string. This worked find with earlier versions of gcc but I had to change to use c++11 for the project. Everything in the tens of thousands of liens of code work as before except the receiveResponse does not return an input stream with data.
The status is 200 OK but the Istrream is just blank. This seems to cause the StreamCopier::copyToString to fail with with malloc/pointer errors ( see bottom of post).
The code is very standard, here it is cleaned up and the URL changed to bbc.co.uk
CODE: SELECT ALL
URI m_uri("http://www.bbc.co.uk");
m_uri.setPort(80);
HTTPClientSession m_session(m_uri.getHost(),m_uri.getPort());
m_uri.setPath("/news/");
string path(m_uri.getPathAndQuery());
// send request
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
m_session.sendRequest(req);
// get response
HTTPResponse res;
istream &is = m_session.receiveResponse(res);
// here is normally some error checking but for this post I just cout the status and get 200 OK
cout << res.getStatus() << " " << res.getReason() << endl;
// Copy response
string results;
// StreamCopier::copyToString(is, results); // Fails with c++11 (malloc/pointer error)
is >> results; // Works for results string is empty.
cout << results <<endl; // blank
Stream Copier Error:
CODE: SELECT ALL
atlasTest(31646) malloc: *** error for object 0x1006c2840: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal SIGABRT, Aborted.
0x00007fff8855982a in __kill ()
(gdb) where
#0 0x00007fff8855982a in __kill () #1 0x00007fff8798ba9c in abort () #2 0x00007fff879ea84c in free () #3 0x00007fff8ef71702 in std::string::_Rep::_M_dispose () #4 0x00007fff8ef72424 in std::string::reserve () #5 0x00007fff8ef7262b in std::string::append () #6 0x000000010081f17f in Poco::StreamCopier::copyToString ()
..... // function that does the http request as above
tested a few different URI and the same issue, I get a status 200 OK but no actual response. Everything was fine pre c++11 installation but I cannot go back to that now.
I downloaded the latest Poco Source from here and compiled/installed but that made no difference.
I spent a couple of hours searching google and trying a few things but to no avail so now I am lost. If I can't get this working we will have to drop Poco and look elsewhere, which is a shame because I really liked the clean API and simplicity!
Any idea what is going on? Any help much appreciated!
The text was updated successfully, but these errors were encountered:
From http://pocoproject.org/forum/viewtopic.php?f=12&t=5933
Postby timstirling » Thu Jul 18, 2013 11:31 am
I am having a problem with HTTPClientSession.receiveResponse since switching to gcc 4.8 using c++11 flags (on maxOsX lion).
I have some simple code that is supposed to connect to a basic http server which responds with a JSON string. This worked find with earlier versions of gcc but I had to change to use c++11 for the project. Everything in the tens of thousands of liens of code work as before except the receiveResponse does not return an input stream with data.
The status is 200 OK but the Istrream is just blank. This seems to cause the StreamCopier::copyToString to fail with with malloc/pointer errors ( see bottom of post).
The code is very standard, here it is cleaned up and the URL changed to bbc.co.uk
CODE: SELECT ALL
Stream Copier Error:
CODE: SELECT ALL
atlasTest(31646) malloc: *** error for object 0x1006c2840: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal SIGABRT, Aborted.
0x00007fff8855982a in __kill ()
(gdb) where
#0 0x00007fff8855982a in __kill ()
#1 0x00007fff8798ba9c in abort ()
#2 0x00007fff879ea84c in free ()
#3 0x00007fff8ef71702 in std::string::_Rep::_M_dispose ()
#4 0x00007fff8ef72424 in std::string::reserve ()
#5 0x00007fff8ef7262b in std::string::append ()
#6 0x000000010081f17f in Poco::StreamCopier::copyToString ()
..... // function that does the http request as above
tested a few different URI and the same issue, I get a status 200 OK but no actual response. Everything was fine pre c++11 installation but I cannot go back to that now.
I downloaded the latest Poco Source from here and compiled/installed but that made no difference.
I spent a couple of hours searching google and trying a few things but to no avail so now I am lost. If I can't get this working we will have to drop Poco and look elsewhere, which is a shame because I really liked the clean API and simplicity!
Any idea what is going on? Any help much appreciated!
The text was updated successfully, but these errors were encountered: