Skip to content

Commit

Permalink
Fix compatibility with websocketpp < 0.8.0
Browse files Browse the repository at this point in the history
.get_headers() method isn't available in older versions
  • Loading branch information
maksis committed Sep 17, 2019
1 parent 380e193 commit 87d1ddc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
24 changes: 1 addition & 23 deletions airdcpp-webapi/web-server/HttpUtil.cpp
Expand Up @@ -226,29 +226,7 @@ namespace webserver {
return true;
}

string HttpUtil::parseCookie(const websocketpp::http::parser::request& aRequest, const string& aCookieName) noexcept {
for (const auto& header : aRequest.get_headers()) {
if (header.first == "Set-Cookie" && header.second.length() > aCookieName.length() && header.second.compare(0, aCookieName.length() + 1, aCookieName + "=") == 0) {
auto value = header.second.substr(aCookieName.length() + 1);

auto separatorPos = value.find(';');
if (separatorPos != string::npos) {
value = value.substr(separatorPos);
}

return value;
}
}

return Util::emptyString;
}

string HttpUtil::parseAuthToken(const websocketpp::http::parser::request& aRequest) noexcept {
auto authToken = aRequest.get_header("Authorization");
//if (authToken == websocketpp::http::empty_header) {
// authToken = parseCookie(aRequest, "Authorization");
//}

return authToken;
return aRequest.get_header("Authorization");
}
}
1 change: 0 additions & 1 deletion airdcpp-webapi/web-server/HttpUtil.h
Expand Up @@ -42,7 +42,6 @@ namespace webserver {

static bool isStatusOk(int aCode) noexcept;
static bool parseStatus(const string& aResponse, int& code_, string& text_) noexcept;
static string parseCookie(const websocketpp::http::parser::request& aRequest, const string& aCookieName) noexcept;
static string parseAuthToken(const websocketpp::http::parser::request& aRequest) noexcept;
};
}
Expand Down

0 comments on commit 87d1ddc

Please sign in to comment.