Skip to content

[WIP] Implement a maximum response size option#902

Open
Gallaecio wants to merge 1 commit into
scrapinghub:masterfrom
Gallaecio:max-response-size
Open

[WIP] Implement a maximum response size option#902
Gallaecio wants to merge 1 commit into
scrapinghub:masterfrom
Gallaecio:max-response-size

Conversation

@Gallaecio

Copy link
Copy Markdown
Contributor

Based on #58.

@codecov

codecov Bot commented May 24, 2019

Copy link
Copy Markdown

Codecov Report

Merging #902 into master will increase coverage by 0.92%.
The diff coverage is 59.57%.

@@            Coverage Diff             @@
##           master     #902      +/-   ##
==========================================
+ Coverage   87.67%   88.59%   +0.92%     
==========================================
  Files          41       41              
  Lines        5726     5807      +81     
  Branches      791      807      +16     
==========================================
+ Hits         5020     5145     +125     
+ Misses        525      482      -43     
+ Partials      181      180       -1
Impacted Files Coverage Δ
splash/server.py 80.64% <100%> (+5.64%) ⬆️
splash/render_options.py 95.72% <100%> (+0.03%) ⬆️
splash/defaults.py 100% <100%> (ø) ⬆️
splash/network_manager.py 77.77% <47.82%> (-6.56%) ⬇️
splash/resources.py 88.57% <87.5%> (-0.11%) ⬇️
splash/qtrender_lua.py 95.8% <0%> (+0.15%) ⬆️
splash/browser_tab.py 93.95% <0%> (+0.78%) ⬆️
splash/qtutils.py 81.69% <0%> (+1.96%) ⬆️
... and 4 more

@Gallaecio
Gallaecio force-pushed the max-response-size branch 5 times, most recently from 1b31cc6 to 8cf3788 Compare May 31, 2019 09:32
@Gallaecio
Gallaecio force-pushed the max-response-size branch from 8cf3788 to 472237d Compare May 31, 2019 10:52
@Gallaecio
Gallaecio force-pushed the max-response-size branch 2 times, most recently from c4d033a to a836917 Compare June 7, 2019 15:49
@Gallaecio
Gallaecio force-pushed the max-response-size branch from a836917 to 9ed7714 Compare June 7, 2019 18:52
Comment thread splash/network_manager.py
return value


def _size_warrants_abort(sizes_and_sources, render_options, log, reply):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function looks over-complicated, can we improve it somehow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can extract some of the inner logic into separate functions, such as the parsing of max_size.

Comment thread splash/defaults.py
MAX_TIMEOUT = 90.0

RESPONSE_SIZE_LIMIT = None
MAX_RESPONSE_SIZE_LIMIT = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This two looks very alike so a bit confusing, please add a comment about what each they stands for?

BTW why do we need two variables for this limit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I recall right:

  • RESPONSE_SIZE_LIMIT is the limit to use as default if the Splash request does not specify one.

  • MAX_RESPONSE_SIZE_LIMIT is the maximum value that a Splash request may specify. If a higher value is specified by a Splash request, MAX_RESPONSE_SIZE_LIMIT is used as limit instead.

It is indeed confusing, I should indeed add a comment.

Comment thread splash/network_manager.py

def _on_reply_download_progress(self, received, total):
reply = self.sender()
request = reply.request()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request is not used

Comment thread splash/network_manager.py
* Tracks information about requests/responses and stores it in HAR format,
including request and response content.
* Allows to set per-request timeouts.
* Handles per-request response size limits.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find how to set the "per-request response size limit" in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding max_size to the render options of a request.

If you mean that the documentation should explain this, indeed.

@Gallaecio Gallaecio left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the early feedback!

However, I don’t think I’ll complete it any time soon, my priorities have switched away from Splash for the time being. If anyone finds this pull request and is interested in completing it, feel free to fork it on a new pull request, and leave a comment about it here.

Comment thread splash/defaults.py
MAX_TIMEOUT = 90.0

RESPONSE_SIZE_LIMIT = None
MAX_RESPONSE_SIZE_LIMIT = None

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I recall right:

  • RESPONSE_SIZE_LIMIT is the limit to use as default if the Splash request does not specify one.

  • MAX_RESPONSE_SIZE_LIMIT is the maximum value that a Splash request may specify. If a higher value is specified by a Splash request, MAX_RESPONSE_SIZE_LIMIT is used as limit instead.

It is indeed confusing, I should indeed add a comment.

Comment thread splash/network_manager.py
return value


def _size_warrants_abort(sizes_and_sources, render_options, log, reply):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can extract some of the inner logic into separate functions, such as the parsing of max_size.

Comment thread splash/network_manager.py
* Tracks information about requests/responses and stores it in HAR format,
including request and response content.
* Allows to set per-request timeouts.
* Handles per-request response size limits.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding max_size to the render options of a request.

If you mean that the documentation should explain this, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants