Skip to content

Commit

Permalink
Fix issue etr#310, but may break existing users.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsgh committed Oct 27, 2023
1 parent d249ba6 commit d3c6de2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/details/http_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@ http_endpoint& http_endpoint::operator =(const http_endpoint& h) {

bool http_endpoint::operator <(const http_endpoint& b) const {
if (family_url != b.family_url) return family_url;
#ifdef CASE_INSENSITIVE
COMPARATOR(url_normalized, b.url_normalized, std::toupper);
#else
#pragma message( \
"WARNING http_endpoint::operator< is always cases insensitive." \
" See https://github.com/etr/libhttpserver/issues/310")
COMPARATOR(url_normalized, b.url_normalized,); // NOLINT(whitespace/comma)
#endif
}

bool http_endpoint::match(const http_endpoint& url) const {
Expand Down
3 changes: 2 additions & 1 deletion test/integ/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ LT_BEGIN_AUTO_TEST(basic_suite, duplicate_endpoints)
#else
// TODO(etr): this should be true.
// However, http_endpoint::operator< is always case-insensitive
LT_CHECK_EQ(false, ws->register_resource("ok", &ok2));
LT_CHECK_EQ(true, ws->register_resource("ok", &ok2));
#endif
LT_END_AUTO_TEST(duplicate_endpoints)

Expand Down Expand Up @@ -1164,6 +1164,7 @@ LT_BEGIN_AUTO_TEST(basic_suite, file_serving_resource_default_content_type)
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &ss);
res = curl_easy_perform(curl);
LT_ASSERT_EQ(res, 0);
LT_CHECK_EQ(s, "test content of file\n");
LT_CHECK_EQ(ss["Content-Type"], "application/octet-stream");
curl_easy_cleanup(curl);
LT_END_AUTO_TEST(file_serving_resource_default_content_type)
Expand Down

0 comments on commit d3c6de2

Please sign in to comment.