我在让 http-client 工作时遇到问题。我已经安装了本指南中的 C++ REST SDK。
我的操作系统是 Debian GNU/Linux 8.3 (jessie)。我也在 Ubuntu 14.04.3 LTS 上测试过,
构建库并运行测试后会出现问题。使用“make test”,输出如下所示:
Start 1: httpclient_test
1/8 Test #1: httpclient_test ..................***Failed 22.87 sec
Start 2: httplistener_test
2/8 Test #2: httplistener_test ................ Passed 1.11 sec
Start 3: json_test
3/8 Test #3: json_test ........................ Passed 0.03 sec
Start 4: pplx_test
4/8 Test #4: pplx_test ........................ Passed 1.37 sec
Start 5: streams_test
5/8 Test #5: streams_test ..................... Passed 5.30 sec
Start 6: uri_test
6/8 Test #6: uri_test ......................... Passed 0.02 sec
Start 7: utils_test
7/8 Test #7: utils_test ....................... Passed 0.02 sec
Start 8: websocketclient_test
8/8 Test #8: websocketclient_test ............. Passed 8.81 sec
88% tests passed, 1 tests failed out of 8
Total Test time (real) = 39.53 sec
The following tests FAILED:
1 - httpclient_test (Failed)
When running './test_runner *_test.so' the errors are:
[...]/casablanca/Release/tests/functional/http/client/authentication_tests.cpp:643: error: Failure in set_user_options_asio_https: Unhandled exception: Error in SSL handshake FAILED
Test case authentication_tests:set_user_options_asio_https FAILED
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:56: error: Failure in outside_cnn_dot_com: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:61: error: Failure in outside_cnn_dot_com: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
Test case outside_tests:outside_cnn_dot_com FAILED
Starting test case outside_tests:outside_google_dot_com...
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:73: error: Failure in outside_google_dot_com: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:73: error: Failure in outside_google_dot_com: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
Test case outside_tests:outside_google_dot_com FAILED
Starting test case outside_tests:multiple_https_requests...
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:87: error: Failure in multiple_https_requests: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:87: error: Failure in multiple_https_requests: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:87: error: Failure in multiple_https_requests: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:87: error: Failure in multiple_https_requests: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:87: error: Failure in multiple_https_requests: CHECK_EQUAL(status_codes::OK, response.status_code()) where status_codes::OK=200 and response.status_code()=302
FAILED
Test case outside_tests:multiple_https_requests FAILED
Starting test case outside_tests:reading_google_stream...
[...]/casablanca/Release/tests/functional/http/client/outside_tests.cpp:107: error: Failure in reading_google_stream: CHECK_EQUAL(strcmp((const char *) chars, "<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org/WebPage\""), 0) where strcmp((const char *) chars, "<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org/WebPage\"")=1 and 0=0
FAILED
Test case outside_tests:reading_google_stream FAILED
**** authentication_tests:set_user_options_asio_https FAILED ****
**** outside_tests:outside_cnn_dot_com FAILED ****
**** outside_tests:outside_google_dot_com FAILED ****
**** outside_tests:multiple_https_requests FAILED ****
**** outside_tests:reading_google_stream FAILED ****
所有其他测试均通过。我不知道我将要做什么。在 Windows 上,我的代码运行良好,在 Linux 上,使用 http_client 发送 http 请求时出现错误。
有谁知道为什么会这样?