Skip to content

Request sni hostname #787

New issue

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

Merged
merged 3 commits into from
Nov 2, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better test
  • Loading branch information
maingoh committed Oct 19, 2017
commit 336fa627e0cccd4eb9afcb4e4639359e0b179ca4
49 changes: 18 additions & 31 deletions libs/network/test/http/client_get_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,27 @@ TYPED_TEST(HTTPClientTest, TemporaryClientObjectTest) {
typedef boost::network::http::basic_client<boost::network::http::tags::http_async_8bit_tcp_resolve, 1, 1> async_client;
#define EXC_PTR(cmd) try { cmd } catch (const std::exception_ptr& ex) { std::rethrow_exception(ex); }

TYPED_TEST(HTTPClientTest, ReuseResponse) {

async_client client;

async_client::request req("https://static.deepomatic.com/compass/NVR_ch2_J_20161209122514_20161209122514_orig.jpg");

req.sni_hostname(req.host());

auto response = client.get(req);

while (!ready(response));

EXC_PTR(response.status(););

// we get the expected headers and body
auto hdrs = headers(response);

for (auto &h : hdrs) {
std::cout << h.first << ": " << h.second << std::endl;
}

std::cout << "---" << std::endl;

req.uri("http://example.com"); // changing the url

response = client.get(req);
TYPED_TEST(HTTPClientTest, GetRequestSNI) {
using client = TypeParam;
// need sni_hostname to be set
typename client::request request("https://www.guide-du-chien.com/wp-content/uploads/2016/10/Beagle.jpg");
typename client::response response;

while (!ready(response));
// trying without setting sni_hostname
ASSERT_NO_THROW(response = client().get(request));
// raise "tlsv1 alert internal error"
ASSERT_THROW(response.status(), std::exception_ptr);

// here the headers are the same as the previous response, they should be those from example.com
auto hdrs2 = headers(response);
// setting sni_hostname
request.sni_hostname(request.host());
ASSERT_NO_THROW(response = client().get(request));
EXPECT_EQ(200u, response.status());

for (auto &h : hdrs2) {
std::cout << h.first << ": " << h.second << std::endl;
try {
auto data = body(response);
std::cout << "Body size: " << data.size() << std::endl;
} catch (...) {
FAIL() << "Caught exception while retrieving body from GET request";
}

}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy