RequestContext::parse_byte_range()

This commit is contained in:
Veloman Yunkan 2020-05-23 17:09:51 +04:00
parent bd2d0bc489
commit c39fce8839
2 changed files with 9 additions and 2 deletions

View File

@ -86,9 +86,14 @@ RequestContext::RequestContext(struct MHD_Connection* connection,
(get_header(MHD_HTTP_HEADER_ACCEPT_ENCODING).find("deflate") != std::string::npos);
} catch (const std::out_of_range&) {}
/*Check if range is requested. */
try {
std::string range = get_header(MHD_HTTP_HEADER_RANGE);
parse_byte_range(range);
} catch (const std::out_of_range&) {}
}
void RequestContext::parse_byte_range(std::string range)
{
const std::string byteUnitSpec("bytes=");
if ( kiwix::startsWith(range, byteUnitSpec) ) {
range.erase(0, byteUnitSpec.size());
@ -110,7 +115,6 @@ RequestContext::RequestContext(struct MHD_Connection* connection,
}
}
}
} catch (const std::out_of_range&) {}
}
RequestContext::~RequestContext()

View File

@ -86,6 +86,9 @@ class RequestContext {
bool can_compress() const { return acceptEncodingDeflate; }
private: // functions
void parse_byte_range(std::string range);
private: // data
std::string full_url;
std::string url;