diff options
-rw-r--r-- | src/Body.cpp | 6 | ||||
-rw-r--r-- | src/DownloadUtils.cpp | 12 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/Body.cpp b/src/Body.cpp index c841f98..fcdc850 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -125,9 +125,9 @@ namespace QuickMedia { replies = other.replies; post_number = other.post_number; userdata = other.userdata; - loaded_height = other.loaded_height; - loaded_image_size = other.loaded_image_size; - loaded_content_height = other.loaded_content_height; + loaded_height = 0.0f; + loaded_image_size = sf::Vector2f(0.0f, 0.0f); + loaded_content_height = 0.0f; embedded_item_status = other.embedded_item_status; if(other.embedded_item) { embedded_item.reset(new BodyItem("")); diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp index afef072..7660cee 100644 --- a/src/DownloadUtils.cpp +++ b/src/DownloadUtils.cpp @@ -29,13 +29,11 @@ namespace QuickMedia { return 0; } - static bool http_is_redirect(const std::string &header, size_t size) { - size_t end_of_first_line = header.find("\r\n"); - if(end_of_first_line == std::string::npos) + static bool http_is_redirect(const char *header, size_t size) { + const void *end_of_first_line_p = memmem(header, size, "\r\n", 2); + if(!end_of_first_line_p) return false; - - size_t find_index = header.find(" 30"); - return find_index != std::string::npos && find_index < size; + return memmem(header, (const char*)end_of_first_line_p - header, " 30", 3) != nullptr; } static int accumulate_string_with_header(char *data, int size, void *userdata) { @@ -49,7 +47,7 @@ namespace QuickMedia { size_t end_of_headers_index = download_userdata->header->find("\r\n\r\n"); if(end_of_headers_index != std::string::npos) { while(true) { - const bool is_redirect = http_is_redirect(*download_userdata->header, end_of_headers_index); + const bool is_redirect = http_is_redirect(download_userdata->header->c_str(), end_of_headers_index); end_of_headers_index += 4; if(is_redirect && download_userdata->header->size() - end_of_headers_index > 0) { download_userdata->header->erase(download_userdata->header->begin(), download_userdata->header->begin() + end_of_headers_index); |