Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Edited Unassigned: the rest sdk doesn't work on win xp [331]

$
0
0
though im unfamilar with c++ & c++ lambda ,but i have wrote a code of client with c++ rest sdk by the references of the web ,it's great framework.it works fine in windows 7, however it's not working on win xp,though i have configured that it targeted win xp,but on winxp,it's missing the "winhttp.dll"(i dont remember the name,but it seems like winhttp.dll).Did i missing something ?in addition, can you comfirm my code is correct if i'd like to used in synchronous method like the following code?(i'd like if it invoke the web address is ok then returns 0,otherwise it returns negative,it dont need extract json)

typedef web::json::value JsonValue;
typedef web::json::value::value_type JsonValueType;
typedef std::wstring String;
typedef std::wstringstream StringStream;

int StringToWString(std::wstring &ws, const std::string &s);
pplx::task<void> HTTPStreamingAsync(std::wstring &theurlw);

int __stdcall callwebaddr(const char * theurl)
{
const std::string theurlstr = theurl;
int nret = 0;
std::wstring theurlw ;
nret = StringToWString(theurlw, theurl);
http_client client(theurlw);



client.request(methods::GET)

.then([](pplx::task<http_response> responseTask)
{
http_response response;
try
{
response = responseTask.get();
}
catch (http_exception &e)
{
if (e.error_code().value() == 12007)
{


std::cerr << "no internet" << std::endl;
return -1;
}
else
{

std::cerr << e.what() << std::endl;

return -2;
}
}

status_code responseStatus = response.status_code();

if (responseStatus == status_codes::Unauthorized)
{

cout << "Incorrect username or password" << std::endl;

return -3;
}

else if (responseStatus != status_codes::OK)
{

cout << "Unexpected result:" << std::endl;

return -4;


}

else
{

return 0;

}
});
return 0;

}


int StringToWString(std::wstring &ws, const std::string &s)
{
std::wstring wsTmp(s.begin(), s.end());

ws = wsTmp;

return 0;
}





Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>