File tree Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -42,36 +42,29 @@ TEST_CASE("SSL")
42
42
43
43
asio::ssl::context ctx (asio::ssl::context::sslv23);
44
44
45
- asio::io_service is ;
45
+ asio::io_context ioc ;
46
46
{
47
- asio::ssl::stream<asio::ip::tcp::socket> c (is , ctx);
47
+ asio::ssl::stream<asio::ip::tcp::socket> c (ioc , ctx);
48
48
c.lowest_layer ().connect (asio::ip::tcp::endpoint (asio::ip::address::from_string (LOCALHOST_ADDRESS), 45460 ));
49
49
50
50
c.handshake (asio::ssl::stream_base::client);
51
51
c.write_some (asio::buffer (sendmsg));
52
52
53
53
size_t x = 0 ;
54
54
size_t y = 0 ;
55
- long z = 0 ;
56
-
57
- while (x < 121 )
58
- {
55
+ // while (x==0)
56
+ // {
59
57
y = c.read_some (asio::buffer (buf, 2048 ));
60
58
x += y;
61
59
buf[y] = ' \0 ' ;
62
- }
60
+ // }
63
61
64
62
std::string to_test (buf);
65
63
66
- if ((z = to_test.length () - 24 ) >= 0 )
67
- {
64
+ auto start_body = to_test.find ( " \r\n\r\n " );
65
+ CHECK (start_body!=std::string::npos);
68
66
69
- CHECK (std::string (" Hello world, I'm keycrt." ) == to_test.substr (z));
70
- }
71
- else
72
- {
73
- CHECK (std::string (" Hello world, I'm keycrt." ).substr ((z * -1 )) == to_test);
74
- }
67
+ CHECK (std::string (" Hello world, I'm keycrt." ) == to_test.substr (start_body+4 ));
75
68
76
69
asio::error_code ec;
77
70
c.lowest_layer ().shutdown (asio::socket_base::shutdown_type::shutdown_both, ec);
You can’t perform that action at this time.
0 commit comments