Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit336fa62

Browse files
committed
Better test
1 parente5e613d commit336fa62

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

‎libs/network/test/http/client_get_test.cpp

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -70,40 +70,27 @@ TYPED_TEST(HTTPClientTest, TemporaryClientObjectTest) {
7070
typedef boost::network::http::basic_client<boost::network::http::tags::http_async_8bit_tcp_resolve,1,1> async_client;
7171
#defineEXC_PTR(cmd)try { cmd }catch (const std::exception_ptr& ex) {std::rethrow_exception(ex); }
7272

73-
TYPED_TEST(HTTPClientTest, ReuseResponse) {
74-
75-
async_client client;
76-
77-
async_client::requestreq("https://static.deepomatic.com/compass/NVR_ch2_J_20161209122514_20161209122514_orig.jpg");
78-
79-
req.sni_hostname(req.host());
80-
81-
auto response = client.get(req);
82-
83-
while (!ready(response));
84-
85-
EXC_PTR(response.status(););
86-
87-
// we get the expected headers and body
88-
auto hdrs =headers(response);
89-
90-
for (auto &h : hdrs) {
91-
std::cout << h.first <<":" << h.second << std::endl;
92-
}
93-
94-
std::cout <<"---" << std::endl;
95-
96-
req.uri("http://example.com");// changing the url
97-
98-
response = client.get(req);
73+
TYPED_TEST(HTTPClientTest, GetRequestSNI) {
74+
using client = TypeParam;
75+
// need sni_hostname to be set
76+
typename client::requestrequest("https://www.guide-du-chien.com/wp-content/uploads/2016/10/Beagle.jpg");
77+
typename client::response response;
9978

100-
while (!ready(response));
79+
// trying without setting sni_hostname
80+
ASSERT_NO_THROW(response =client().get(request));
81+
// raise "tlsv1 alert internal error"
82+
ASSERT_THROW(response.status(), std::exception_ptr);
10183

102-
// here the headers are the same as the previous response, they should be those from example.com
103-
auto hdrs2 =headers(response);
84+
// setting sni_hostname
85+
request.sni_hostname(request.host());
86+
ASSERT_NO_THROW(response =client().get(request));
87+
EXPECT_EQ(200u, response.status());
10488

105-
for (auto &h : hdrs2) {
106-
std::cout << h.first <<":" << h.second << std::endl;
89+
try {
90+
auto data =body(response);
91+
std::cout <<"Body size:" << data.size() << std::endl;
92+
}catch (...) {
93+
FAIL() <<"Caught exception while retrieving body from GET request";
10794
}
10895

10996
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp