Fix Ferrum::Network::Response#loaded?
for redirect response
#328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #321
Context
Redirect
Ferrum::Network::Response
are created within theNetwork.requestWillBeSent
event:ferrum/lib/ferrum/network.rb
Lines 358 to 366 in e2340b3
Additionally, the
Network.loadingFinished
event is where responses are marked asloaded = true
:ferrum/lib/ferrum/network.rb
Lines 386 to 392 in e2340b3
As redirect responses are sharing the same
requestId
and as that code is only selecting the last exchange response e.g. the final response, only that exchange response is marked asloaded?
.Proposed fix
Assigning
loaded = true
at the time that redirect response object is created.Note: Unfortunately I'm running into issues executing tests locally so I didn't add any. Per my quick testing, it looks to be solving the aforementioned issue.