Skip to content

requests: Match response header names case-insensitively. - #1147

Open
pablogventura wants to merge 2 commits into
micropython:masterfrom
pablogventura:requests-case-insensitive-headers
Open

requests: Match response header names case-insensitively.#1147
pablogventura wants to merge 2 commits into
micropython:masterfrom
pablogventura:requests-case-insensitive-headers

Conversation

@pablogventura

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • Unix test_requests.py, including lowercase transfer-encoding chunked and location redirect cases.
  • __init__.mpy (mpy-cross, compiled as __init__.py): master 3160, this PR 3169 (+9).

Signed-off-by: Pablo Ventura <pablogventura@gmail.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this line now be if lowerl.startswith(b"content-length:")? That saves a call to lower() and the associated memory overhead.

Signed-off-by: Pablo Ventura <pablogventura@gmail.com>
@pablogventura

Copy link
Copy Markdown
Contributor Author

Thanks. Applied in e0d0462: if lowerl.startswith(b"content-length:") instead of k.lower() == "content-length", plus a lowercase content-length test.

__init__.mpy (mpy-cross, compiled as __init__.py): master 3160, previous on this branch 3169 (+9), e0d0462 still 3169 (+9). Same bytecode size; avoids the extra .lower() at runtime.

Unix test_requests.py passes.

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