We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
void sendHTTP(std::string strurl) { try { std::wstring url = StringToWString(strurl); web::http::client::http_client_config client_config; client_config.set_timeout(std::chrono::seconds(10000)); web::http::client::http_client client(url, client_config); auto task = client.request(web::http::methods::POST); } catch (web::uri_exception) { std::cout << "uri_exception" << std::endl; } catch (web::json::details::json_error) { std::cout << "json_error" << std::endl; } catch (web::json::json_exception) { std::cout << "json_exception" << std::endl; } catch (web::web_proxy::web_proxy_mode) { std::cout << "web_proxy_mode" << std::endl; } catch (...) { std::cout << "sendHTTP error" << std::endl; }
// .then([](web::http::http_response resp) { // return resp.extract_string(); //}).then([](utility::string_t jsonStr) //{ // return jsonStr; //}); //task.wait(); //utility::string_t respStr = task.get(); }
int main() { while(true) { Sleep(10); std::string URL = "http://127.0.0.1:8080/test/test.go&data="+ URLEncode("{"row":[{"test":34,"test2" : 1}, {"test":34,"test2" : 1}]}");//网址不存在 sendHTTP(URL); } return 0; }
The text was updated successfully, but these errors were encountered:
@chxuan
Sorry, something went wrong.
@zhanMan 异步接口肯定不能够通过try catch来捕获异常,你看看它异步返回值里面有没有什么参数可以说明返回失败了呢?
No branches or pull requests
void sendHTTP(std::string strurl)
{
try
{
std::wstring url = StringToWString(strurl);
web::http::client::http_client_config client_config;
client_config.set_timeout(std::chrono::seconds(10000));
web::http::client::http_client client(url, client_config);
auto task = client.request(web::http::methods::POST);
}
catch (web::uri_exception)
{
std::cout << "uri_exception" << std::endl;
}
catch (web::json::details::json_error)
{
std::cout << "json_error" << std::endl;
}
catch (web::json::json_exception)
{
std::cout << "json_exception" << std::endl;
}
catch (web::web_proxy::web_proxy_mode)
{
std::cout << "web_proxy_mode" << std::endl;
}
catch (...)
{
std::cout << "sendHTTP error" << std::endl;
}
// .then([](web::http::http_response resp) {
// return resp.extract_string();
//}).then([](utility::string_t jsonStr)
//{
// return jsonStr;
//});
//task.wait();
//utility::string_t respStr = task.get();
}
int main()
{
while(true)
{
Sleep(10);
std::string URL = "http://127.0.0.1:8080/test/test.go&data="+ URLEncode("{"row":[{"test":34,"test2" : 1}, {"test":34,"test2" : 1}]}");//网址不存在
sendHTTP(URL);
}
return 0;
}
The text was updated successfully, but these errors were encountered: