Closed
Conversation
- Performance improved by reducing function calls
Owner
|
Thanks for the contribution, @ademmenh ! I'm going to close this one — HTTP/2 Server Push has been removed from all major browsers, so |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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.
Pull Request: Optimize Header Handling for Server Push
Description
This pull request introduces a new
get_raw_listmethod to theHeadersdatastructure and leverages it to optimize thesend_push_promisefunction in theRequestclass.The primary goal is to reduce unnecessary decoding and encoding overhead when dealing with raw header bytes during server push operations.
Changes
Core Changes
starlette/datastructures.py:Headers.get_raw_list(key: str) -> list[bytes]: Retrieves the raw byte values for a given header key.starlette/requests.py:send_push_promise(internal logic withinRequest) to useget_raw_list.decode("latin-1")->encode("latin-1")cycle for header values.Tests
tests/test_datastructures.py:get_raw_listcorrectly returns byte values for multi-value headers.