Skip to content
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

Do not consider http 304 a request failure #126

Merged
merged 3 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/grover/js/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
const raiseOnRequestFailure = options.raiseOnRequestFailure; delete options.raiseOnRequestFailure;
if (raiseOnRequestFailure) {
page.on('requestfinished', (request) => {
if (request.response() && !request.response().ok() && !request.redirectChain().length > 0) {
if (request.response() && !(request.response().ok() || request.response().status() == 304) && !request.redirectChain().length > 0) {
errors.push(request);
}
});
Expand Down
15 changes: 15 additions & 0 deletions spec/grover/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,21 @@
end
end

context 'when a 304 occurs it does not raise an error' do
let(:url_or_html) do
<<-HTML
<html>
<body>
Hey there
<img src="https://httpstat.us/304" />
</body>
</html>
HTML
end

it { expect(pdf_text_content).to include 'Hey there' }
end

context 'when assets have redirects PDFs are generated successfully' do
it { expect(pdf_text_content).to match "#{date} Google" }
end
Expand Down