Skip to content

Commit 6b6720a

Browse files
committed
White space and Test Case
Tidied up whitespace in http_listener.cpp Added new member variable m_sercure_uri to class uri_address and intialized it with "https://localhost:8443/". Created simple test case called https_listener to test https support.
1 parent 5bfdea5 commit 6b6720a

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

Release/src/http/listener/http_listener.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ static void check_listener_uri(const http::uri &address)
4141
// We only need to check certain things specific to HTTP.
4242

4343
#ifdef _MS_WINDOWS
44-
//HTTP Server API includes SSL support
45-
if (address.scheme() != U("http") && address.scheme() != U("https"))
46-
{
47-
throw std::invalid_argument("URI scheme must be 'http' or 'https'");
48-
}
44+
//HTTP Server API includes SSL support
45+
if (address.scheme() != U("http") && address.scheme() != U("https"))
46+
{
47+
throw std::invalid_argument("URI scheme must be 'http' or 'https'");
48+
}
4949
#else
50-
if (address.scheme() == U("https"))
51-
{
52-
throw std::invalid_argument("Listeners using 'https' are not yet supported");
53-
}
54-
55-
if (address.scheme() != U("http"))
56-
{
57-
throw std::invalid_argument("URI scheme must be 'http'");
58-
}
50+
if (address.scheme() == U("https"))
51+
{
52+
throw std::invalid_argument("Listeners using 'https' are not yet supported");
53+
}
54+
55+
if (address.scheme() != U("http"))
56+
{
57+
throw std::invalid_argument("URI scheme must be 'http'");
58+
}
5959
#endif
6060

6161
if(address.host().empty())

Release/tests/Functional/http/listener/http_listener_tests.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ namespace tests { namespace functional { namespace http { namespace listener {
2222
class uri_address
2323
{
2424
public:
25-
uri_address() : m_uri(U("http://localhost:34567/"))
25+
uri_address() :
26+
m_uri(U("http://localhost:34567/")),
27+
m_secure_uri(U("https://localhost:8443/"))
2628
{
2729
if (!s_dummy_listener)
2830
s_dummy_listener = std::make_shared<web::http::experimental::listener::http_listener>(U("http://localhost:30000/"));
@@ -33,6 +35,7 @@ class uri_address
3335

3436
static std::shared_ptr<web::http::experimental::listener::http_listener> s_dummy_listener;
3537
web::http::uri m_uri;
38+
web::http::uri m_secure_uri;
3639
};
3740

3841
}}}}

Release/tests/Functional/http/listener/requests_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,22 @@ TEST_FIXTURE(uri_address, uri_encoding)
234234
encoded_uri = uri::encode_uri(U("/path 1/path 2?key1=val1 val2#fragment1")); // URI has path, query and fragment components
235235
client.request(methods::GET, encoded_uri).wait();
236236
}
237+
238+
TEST_FIXTURE(uri_address, https_listener)
239+
{
240+
http_listener listener(m_secure_uri);
241+
listener.open().wait();
242+
client::http_client client(m_secure_uri);
243+
244+
listener.support([&](http_request request)
245+
{
246+
request.reply(status_codes::OK);
247+
});
248+
249+
http_asserts::assert_response_equals(client.request(methods::GET, U("")).get(), status_codes::OK);
250+
251+
listener.close().wait();
252+
}
237253
}
238254

239255
}}}}

0 commit comments

Comments
 (0)