Revert "log_services: Add download of post code log entries"
This reverts commit af61db10fb40c7beb91a70f0b3ff28cb8e6c1704 which
breaks the ability to detect and post json content as HTTP. I suspect
something went wrong with the requestPrefersHtml() method that was
modified in this commit. Authors should feel free to resubmit this
patch once they have the failure understood and fixed.
Change-Id: Id6e8d102fe5d4b02ac0dce06bff50c28edfcf44c
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index d04fd93..119a1ee 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -5,24 +5,21 @@
namespace http_helpers
{
-inline std::string parseAccept(const crow::Request& req)
-{
- std::string_view acceptHeader = req.getHeaderValue("Accept");
- // The iterators in boost/http/rfc7230.hpp end the string if '/' is found,
- // so replace it with arbitrary character '|' which is not part of the
- // Accept header syntax.
- return boost::replace_all_copy(std::string(acceptHeader), "/", "|");
-}
-
inline bool requestPrefersHtml(const crow::Request& req)
{
- for (const auto& param : boost::beast::http::ext_list{parseAccept(req)})
+ std::string_view header = req.getHeaderValue("accept");
+ std::vector<std::string> encodings;
+ // chrome currently sends 6 accepts headers, firefox sends 4.
+ encodings.reserve(6);
+ boost::split(encodings, header, boost::is_any_of(", "),
+ boost::token_compress_on);
+ for (const std::string& encoding : encodings)
{
- if (param.first == "text|html")
+ if (encoding == "text/html")
{
return true;
}
- if (param.first == "application|json")
+ if (encoding == "application/json")
{
return false;
}
@@ -30,18 +27,6 @@
return false;
}
-inline bool isOctetAccepted(const crow::Request& req)
-{
- for (const auto& param : boost::beast::http::ext_list{parseAccept(req)})
- {
- if (param.first == "*|*" || param.first == "application|octet-stream")
- {
- return true;
- }
- }
- return false;
-}
-
inline std::string urlEncode(const std::string_view value)
{
std::ostringstream escaped;