updated!!
filtered file size > 512k is prone to load implete on 32bit version
the issue occurs often but not each time on the same site.
I first come across such issue from cef3239 (chromium 63), the same issue can be repoduced on cef 4389 (chromium 89) as well.
But on older version cef2623 (chromium 49), it works as expected.
what should be noticed on response filter?
What I have done on cefclient (cef 2623, 3239, 4389)
change the codes as below
- Code: Select all
//const char kFindString[] = "REPLACE_THIS_STRING";
//const char kReplaceString[] = "This is the replaced string!";
const char kFindString[] = "_top";
const char kReplaceString[] = "_self";
FilterStatus Filter(void* data_in,
size_t data_in_size,
size_t& data_in_read,
void* data_out,
size_t data_out_size,
size_t& data_out_written) OVERRIDE {
DCHECK((data_in_size == 0U && !data_in) || (data_in_size > 0U && data_in));
DCHECK_EQ(data_in_read, 0U);
DCHECK(data_out);
DCHECK_GT(data_out_size, 0U);
DCHECK_EQ(data_out_written, 0U);
// All data will be read.
data_in_read = data_in_size;
const size_t find_size = sizeof(kFindString) - 1;
const size_t replace_size = sizeof(kReplaceString) - 1;
const char* data_in_ptr = static_cast<char*>(data_in);
char* data_out_ptr = static_cast<char*>(data_out);
// Reset the overflow.
std::string old_overflow;
if (!overflow_.empty()) {
old_overflow = overflow_;
overflow_.clear();
}
const size_t likely_out_size =
data_in_size + replace_overflow_size_ + old_overflow.size();
if (data_out_size < likely_out_size) {
// We'll likely need to use the overflow buffer. Size it appropriately.
overflow_.reserve(likely_out_size - data_out_size);
}
if (!old_overflow.empty()) {
// Write the overflow from last time.
Write(old_overflow.c_str(), old_overflow.size(), WRITE_PARAMS);
}
// Evaluate each character in the input buffer. Track how many characters in
// a row match kFindString. If kFindString is completely matched then write
// kReplaceString. Otherwise, write the input characters as-is.
for (size_t i = 0U; i < data_in_size; ++i) {
if (data_in_ptr[i] == kFindString[find_match_offset_]) {
// Matched the next character in the find string.
if (++find_match_offset_ == find_size) {
// Complete match of the find string. Write the replace string.
//std::stringstream ss;
//ss << ++replace_count_ << ". " << kReplaceString;
//const std::string& replace_str = ss.str();
Write(kReplaceString, replace_size, WRITE_PARAMS);
// Start over looking for a match.
find_match_offset_ = 0;
}
continue;
}
// Character did not match the find string.
if (find_match_offset_ > 0) {
// Write the portion of the find string that has matched so far.
Write(kFindString, find_match_offset_, WRITE_PARAMS);
// Start over looking for a match.
find_match_offset_ = 0;
}
// Write the current character.
Write(&data_in_ptr[i], 1, WRITE_PARAMS);
}
// If a match is currently in-progress we need more data. Otherwise, we're
// done.
return find_match_offset_ > 0 ? RESPONSE_FILTER_NEED_MORE_DATA
: RESPONSE_FILTER_DONE;
}
//if (test_runner::IsTestURL(url, kTestUrlPath))
return new FindReplaceResponseFilter();
then visit
https://s.taobao.com/search?spm=a21bo.21814703.201867-links-1.1.5af911d9b9hud3&q=%E5%A5%B3%E6%97%B6%E8%A3%85%E5%87%89%E9%9E%8B&cps=yes&ppath=20000%3A97466
result
page
resource missing
content incomplete