-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update documentation and refactor Rack::Test::Session #295
Merged
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
Metaprogram the HTTP verb methods to reduce duplication. Remove need for @headers instance variable, by having header method do the name mangling and storing the result in @env. In addition to being simpler, this is also faster as it avoids the need to mangling the names in every request. When mangling names, avoid unnecessary string allocations. Also remove the @default_host instance variable, since it was only used in one place. Avoid array allocation in follow_redirect!. Also avoid unnecessary indirection by using custom_request directly. This will also fix cases where there is a redirect following a custom_request with an HTTP verb for which there is no method. Avoid unnecessary string allocation and method calls in parse_uri. Remove default_env and headers_for_env private methods. Both were only used in one place. headers_for_env is no longer needed after the change to header, and default_env is simple enough to inline. Use a private frozen constant as the default environment. Remove inaccurate comments in env_for. We decided not to remove support for :method, since it is still supported in Rack, and Rack::ContentLength has never dealt with Content-Length in requests, only Content-Length in responses. Remove unnecessary array allocations in env_for as well. Require forwardable, since it is used in this file, instead of relying on the fact that rack/test/methods currently requires forwardable.
ioquatix
reviewed
May 11, 2022
ioquatix
reviewed
May 11, 2022
ioquatix
reviewed
May 11, 2022
ioquatix
approved these changes
May 11, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor feedback.
This is compatible with earlier versions of Rack, and lower-case headers are required in Rack 3. Accessing the headers for the last response uses a case insensitive match. This also changes the headers used in multipart requests, for consistency, even though that is not required by the rack SPEC. While here, remove some bogus comments in the specs about Rack::ContentLength setting content length for requests.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
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.
See individual commits for changes.