New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The content is always wrapped in HTML #55
Comments
Looking at the code, the decoded_content method is treating the content as HTML: sub decoded_content($self) {
$self->document_future->then(sub( $root ) {
# Join _all_ child nodes together to also fetch DOCTYPE nodes
# and the stuff that comes after them
my @content = map {
my $nodeId = $_->{nodeId};
$self->log('trace', "Fetching HTML for node " . $nodeId );
$self->target->send_message('DOM.getOuterHTML', nodeId => 0+$nodeId )
} @{ $root->{root}->{children} };
Future->wait_all( @content )
})->then( sub( @outerHTML_f ) {
Future->done( join "", map { $_->get->{outerHTML} } @outerHTML_f )
})->get;
}; It should check the content type, and perhaps just return the raw content instead? |
Yes, this is an ugly problem. Can you see if the following works well enough for your use case(s)? It uses the content from the response, but that content will already have been decoded and I'm not sure how well it works with binary content:
|
That works for JSON data, but I get an error for HTML pages:
|
Whoops - sorry, I didn't run the test suite properly. This one passes my new test and the existing test suite - does it work for your case too?
|
This seems better. |
When requesting something that returns a non-HTML document, e.g. application/json, if the response from the server is HTTP 304, then the content_type is undefined but the content (presumably the cached content) is wrapped in HTML, e.g.
This consistently happens when the response is HTTP 304, but this seems to happen sometimes when the response is HTTP 200.
The text was updated successfully, but these errors were encountered: