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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes from1 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
PrevPrevious commit
NextNext commit
Better test
  • Loading branch information
@maingoh
maingoh committedOct 19, 2017
commit336fa627e0cccd4eb9afcb4e4639359e0b179ca4
49 changes: 18 additions & 31 deletionslibs/network/test/http/client_get_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff 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";
}

}

[8]ページ先頭

©2009-2025 Movatter.jp