this function is modified from ```instaweb_in_place_filter``` and ```instaweb_in_place_check_headers_filter```.