aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/MangaGeneric.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-10 18:49:44 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-10 22:41:04 +0200
commitcdf8d103f1ed6a932eb30b589b578d23ca66a514 (patch)
tree0782751764748be50c4203b8e1af14907046e3d2 /src/plugins/MangaGeneric.cpp
parent2eac1e3d3ece90d1c522e15cb57ee41baa3dd822 (diff)
Add downloader, fix room navigation lag
Fix bug where getting next page fails if there is no search bar
Diffstat (limited to 'src/plugins/MangaGeneric.cpp')
-rw-r--r--src/plugins/MangaGeneric.cpp30
1 files changed, 1 insertions, 29 deletions
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;