-
-
Notifications
You must be signed in to change notification settings - Fork 813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate URL.is_ssl
#1128
Deprecate URL.is_ssl
#1128
Conversation
|
@StephenBrown2 Not, not an invalid URL per se anymore. :-) >>> import httpx # @ master
>>> httpx.URL('ftps://localhost/test.txt')
URL('ftps://localhost/test.txt') # Would have raised an exception on 0.13.x. The decision of "is this scheme valid?" has been deferred to the transport layer - see #1080. |
@@ -140,6 +140,8 @@ def raw(self) -> typing.Tuple[bytes, bytes, typing.Optional[int], bytes]: | |||
|
|||
@property | |||
def is_ssl(self) -> bool: | |||
message = 'URL.is_ssl() is pending deprecation. Use url.scheme == "https"' | |||
warnings.warn(message, DeprecationWarning) |
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.
Note: we have a handy util in _utils.py
so we don't have to remember which warning category should be passed (planning to issue a PR to update all usage to this shortly!).
warnings.warn(message, DeprecationWarning) | |
warn_deprecated(message) |
Yes, but that still means it's an invalid URL as far as httpx is concerned:
Or are you implying that one could make their own transport handler to deal with non-http schemes? |
Sure, the default connection pool transport can't handle Edit: oh, wait, I think we haven't made the switch to "defer scheme validation to transports" just yet (see how the error comes from an assertion made in |
In either case the point would still stand, which is that we've got a nicer API now that |
This is one of those niggly little API bits that have only ended up in here because of implementation details.
We're not using
url.is_ssl
anywhere in our codebase, and now that we're agnostic to protocols except at the transport layer, this API doesn't feel right. (Egftps://...
is an SSL URL, but would return false here.)If any users are using this, they should migrate to a more explicit
if url.scheme == "https":
.