@@ -70,40 +70,27 @@ TYPED_TEST(HTTPClientTest, TemporaryClientObjectTest) {
70
70
typedef boost::network::http::basic_client<boost::network::http::tags::http_async_8bit_tcp_resolve,1 ,1 > async_client;
71
71
#define EXC_PTR (cmd )try { cmd }catch (const std::exception_ptr& ex) {std::rethrow_exception (ex); }
72
72
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;
99
78
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);
101
83
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 ());
104
88
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" ;
107
94
}
108
95
109
96
}