From cdf8d103f1ed6a932eb30b589b578d23ca66a514 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 10 May 2021 18:49:44 +0200 Subject: Add downloader, fix room navigation lag Fix bug where getting next page fails if there is no search bar --- src/plugins/MangaGeneric.cpp | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'src/plugins/MangaGeneric.cpp') diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp index a6df1c1..2e88d60 100644 --- a/src/plugins/MangaGeneric.cpp +++ b/src/plugins/MangaGeneric.cpp @@ -121,34 +121,6 @@ namespace QuickMedia { }, page_image_userdata); } - static size_t str_find_case_insensitive(const std::string &str, size_t start_index, const char *substr, size_t substr_len) { - auto it = std::search(str.begin() + start_index, str.end(), substr, substr + substr_len, - [](char c1, char c2) { - return std::toupper(c1) == std::toupper(c2); - }); - if(it == str.end()) - return std::string::npos; - return it - str.begin(); - } - - static std::string header_extract_location(const std::string &headers) { - size_t index = str_find_case_insensitive(headers, 0, "location:", 9); - if(index != std::string::npos && (index == 0 || headers[index - 1] == '\n')) { - index += 9; - size_t end = headers.find('\r', index); - size_t start = index; - while(start < end) { - char c = headers[start]; - if(c != ' ' && c != '\t') - break; - ++start; - } - if(end - start > 0) - return headers.substr(start, end - start); - } - return ""; - } - MangaGenericSearchPage::MangaGenericSearchPage(Program *program, const char *service_name, const char *website_url, bool fail_on_http_error) : Page(program), service_name(service_name), website_url(website_url ? website_url : ""), fail_on_http_error(fail_on_http_error) { @@ -228,7 +200,7 @@ namespace QuickMedia { goto cleanup; } - target_url = header_extract_location(response_headers); + target_url = header_extract_value(response_headers, "location"); if(target_url.empty()) { fprintf(stderr, "Failed to extract target location from %s HEAD\n", url.c_str()); result = -1; -- cgit v1.2.3