Skip to content

some question about PartI-"downloading web page" #380

Answered by shuhei
zhang14725804 asked this question in Q&A
Discussion options

You must be logged in to vote

For the question 1, a socket needs to be created before you wrap it with SSL (actually TLS). So,

    s = socket.socket(
        family=socket.AF_INET,
        type=socket.SOCK_STREAM,
        proto=socket.IPPROTO_TCP,
    )

should come before:

    if scheme == "https":
        ctx = ssl.create_default_context()
        s = ctx.wrap_socket(s,server_hostname=host)

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@shuhei
Comment options

@zhang14725804
Comment options

@pavpanchekha
Comment options

@pavpanchekha
Comment options

Answer selected by pavpanchekha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants