Fix URL parsing over segmented reads
parent
bcafb38482
commit
6d82f7ddaf
|
|
@ -440,12 +440,17 @@ int PreambleGetter::DoReadComplete(size_t preamble_index, int result) {
|
|||
if (result <= 0) {
|
||||
return result;
|
||||
}
|
||||
if (preamble_index != 0) {
|
||||
// Skips parsing non-root pages, which is not decoded yet.
|
||||
return OK;
|
||||
}
|
||||
|
||||
CHECK_LT(preamble_index, requests_.size());
|
||||
Request& req = *requests_[preamble_index];
|
||||
|
||||
std::string_view html(req.read_buffer->data(), static_cast<size_t>(result));
|
||||
std::vector<std::string_view> links = ExtractLinkAndScriptURLs(html);
|
||||
std::string_view new_data(req.read_buffer->data(), static_cast<size_t>(result));
|
||||
req.last_content.append(new_data);
|
||||
std::vector<std::string_view> links = ExtractLinkAndScriptURLs(req.last_content);
|
||||
for (std::string_view link : links) {
|
||||
GURL gurl = root_.Resolve(link);
|
||||
if (!gurl.is_valid())
|
||||
|
|
@ -486,6 +491,7 @@ int PreambleGetter::DoReadComplete(size_t preamble_index, int result) {
|
|||
requests_.back()->ext = ext;
|
||||
(void)Start(requests_.size() - 1, {});
|
||||
}
|
||||
req.last_content = new_data;
|
||||
req.next_state = STATE_READ;
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ class PreambleGetter {
|
|||
std::make_unique<ClientSocketHandle>();
|
||||
std::unique_ptr<SourceStream> upstream;
|
||||
scoped_refptr<IOBuffer> read_buffer;
|
||||
std::string last_content;
|
||||
CompletionOnceCallback callback;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue