c++ - Prevent winHTTP From Writing to STDOUT -


i've taken following code previous post:

//variables dword dwsize = 0; dword dwdownloaded = 0; lpstr pszoutbuffer; std::vector <std::string>  vfilecontent; bool  bresults = false; hinternet  hsession = null,            hconnect = null,            hrequest = null;  // use winhttpopen obtain session handle. hsession = winhttpopen( l"winhttp example/1.0",                         winhttp_access_type_default_proxy,                         winhttp_no_proxy_name,                         winhttp_no_proxy_bypass, 0);  // specify http server. if (hsession)     hconnect = winhttpconnect( hsession, l"stackoverflow.com",                                internet_default_http_port, 0);  // create http request handle. if (hconnect)     hrequest = winhttpopenrequest( hconnect, l"get", l"/questions/ask/",                                    null, winhttp_no_referer,                                    null,                                    null);  // send request. if (hrequest)     bresults = winhttpsendrequest( hrequest,                                    winhttp_no_additional_headers,                                    0, winhttp_no_request_data, 0,                                    0, 0);   // end request. if (bresults)     bresults = winhttpreceiveresponse( hrequest, null);  // keep checking data until there nothing left. if (bresults)     do{         // check available data.         dwsize = 0;         if (!winhttpquerydataavailable( hrequest, &dwsize))             printf( "error %u in winhttpquerydataavailable.\n",                     getlasterror());          // allocate space buffer.         pszoutbuffer = new char[dwsize+1];         if (!pszoutbuffer)         {             printf("out of memory\n");             dwsize=0;         }         else         {             // read data.             zeromemory(pszoutbuffer, dwsize+1);              if (!winhttpreaddata( hrequest, (lpvoid)pszoutbuffer,                                   dwsize, &dwdownloaded))             {                 printf( "error %u in winhttpreaddata.\n",                         getlasterror());             }             else             {                         printf("%s", pszoutbuffer);                             // data in vfilecontent                 vfilecontent.push_back(pszoutbuffer);             }              // free memory allocated buffer.             delete [] pszoutbuffer;         }      } while (dwsize>0);   // report errors. if (!bresults)     printf("error %d has occurred.\n",getlasterror());  // close open handles. if (hrequest) winhttpclosehandle(hrequest); if (hconnect) winhttpclosehandle(hconnect); if (hsession) winhttpclosehandle(hsession);  // write vfilecontent file std::ofstream out("./so/ask.html",std::ios::app); (int = 0; < (int) vfilecontent.size();i++) out << vfilecontent[i]; out.close(); 

when run downloads file , prints it's data. looked through code, , couldn't find writing data stdout. can tell me it's coming , how prevent it?

the line:

printf("%s", ppszoutbuffer); 

i believe reason here.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -