Skip to content

Commit

Permalink
add ssl import for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishtr committed Dec 27, 2024
1 parent dffc9d7 commit 1985ab7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion book/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ Let's try to take this code and add it to `request`. First, we need to
detect which scheme is being used:

``` {.python}
import ssl
class URL:
def __init__(self, url):
self.scheme, url = url.split("://", 1)
Expand Down Expand Up @@ -843,7 +845,7 @@ class URL:
def request(self):
# ...
s.connect((self.host, self.port))
p if self.scheme == "https":
if self.scheme == "https":
ctx = ssl.create_default_context()
s = ctx.wrap_socket(s, server_hostname=self.host)
# ...
Expand Down

0 comments on commit 1985ab7

Please sign in to comment.