Skip to content

Conversation

@RafaelWO
Copy link
Contributor

@RafaelWO RafaelWO commented Nov 1, 2024

Summary

Related issue: #3381

This PR moves the following remaining utility functions from _utils.py to _client.py that are only used in _client.py:

  • port_or_default
  • same_origin
  • is_https_redirect

Related tests are also moved accordingly (to tests/client/test_headers.py)

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@RafaelWO RafaelWO force-pushed the change/move-utils-to-client branch from acf4ca6 to 53ed14e Compare November 2, 2024 09:21
@RafaelWO
Copy link
Contributor Author

RafaelWO commented Nov 2, 2024

I am not sure whether we should also move the class URLPattern - it is only used in _client.py. Maybe it should go into its own file or _urls.py?

@lovelydinosaur
Copy link
Contributor

Ah this is an interesting one.

I'm going to suggest leaving the following in _utils.py for the moment...

  • URLPattern
  • get_environment_proxies
  • is_ipv4_hostname
  • is_ipv6_hostname

We'll likely be able to remove them entirely due to a different piece of incoming refactoring, tho will treat that seperately.

The following functions are moved because they are only used in _client.py
* port_or_default
* same_origin
* is_https_redirect

Related tests are also moved accordingly.
@RafaelWO RafaelWO force-pushed the change/move-utils-to-client branch from 53ed14e to c36f07d Compare November 6, 2024 18:55
@RafaelWO
Copy link
Contributor Author

@tomchristie, I updated the PR accordingly 🙂

Copy link
Contributor

@lovelydinosaur lovelydinosaur left a comment

Choose a reason for hiding this comment

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

Thanks, yes. Neatly done. ☺️

@lovelydinosaur lovelydinosaur merged commit 7b19cd5 into encode:master Nov 15, 2024
5 checks passed
@RafaelWO RafaelWO deleted the change/move-utils-to-client branch November 15, 2024 15:37
samclearman pushed a commit to titanmsp/httpx that referenced this pull request Apr 26, 2025
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