This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 670
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
introduce a handler struct, which - enables lifting of all the handle* closures to methods - eliminates the passing around of defaultMaxResponseSize - reduces the number of free-floating functions
no need to do a binary search if all the answers fit
} | ||
|
||
// pick a random max size, truncate response to that, check it | ||
maxSize := 512 + rand.Intn(response.Len()-512) | ||
truncateResponse(response, maxSize) | ||
maxSize := 512 + rand.Intn(2*512) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
If you stick ?w=1 on the end of the url, github will also ignore whitespace. |
Thanks! Looks much better that way. |
continue | ||
} | ||
response.Id = req.Id | ||
if response.Len() > h.getMaxResponseSize(req) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Whilst you're refactoring, you could move errorResponse onto handler and move it down the file to be with makeResponse. |
Also should errorResponse use respond too? |
and implement it in terms of existing functions, plus provide a convenience method for sending the rather common NameError.
That last change looks good to; merge away. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This takes the refactoring bit of #1334, evolves it (the handler construction is neater here), adds some extra refactors, and an optimisation.
Best reviewed by looking at the individual commits. And the first of those is best view in a good diff viewer, e.g. kompare in whitespace-ignore mode, where it will appear much smaller than here on github.