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

[WIP] Implement a maximum response size option #902

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gallaecio
Copy link
Member

Based on #58.

@codecov
Copy link

codecov bot commented May 24, 2019

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 2 times, most recently from c4d033a to a836917 Compare June 7, 2019 15:49
return value


def _size_warrants_abort(sizes_and_sources, render_options, log, reply):
Copy link
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
Member 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.

@@ -6,6 +6,9 @@

MAX_TIMEOUT = 90.0

RESPONSE_SIZE_LIMIT = None
MAX_RESPONSE_SIZE_LIMIT = None
Copy link
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
Member 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.

@@ -413,6 +502,16 @@ def _on_reply_headers(self):
self.log("Headers received for {url}", reply, min_level=3)

def _on_reply_download_progress(self, received, total):
reply = self.sender()
request = reply.request()
Copy link
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

@@ -86,6 +153,7 @@ class ProxiedQNetworkAccessManager(QNetworkAccessManager):
* 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
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
Member 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.

Copy link
Member Author

@Gallaecio Gallaecio left a comment

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.

@@ -6,6 +6,9 @@

MAX_TIMEOUT = 90.0

RESPONSE_SIZE_LIMIT = None
MAX_RESPONSE_SIZE_LIMIT = None
Copy link
Member 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.

return value


def _size_warrants_abort(sizes_and_sources, render_options, log, reply):
Copy link
Member 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.

@@ -86,6 +153,7 @@ class ProxiedQNetworkAccessManager(QNetworkAccessManager):
* 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
Member 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