Skip to content

Commit 1071e73

Browse files
authored
Merge pull request #1045 from breadsh/master
correct code in the doc
2 parents 8fbce23 + c49f948 commit 1071e73

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

docs/source/basic-usage.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,11 @@ The function should look something like this:
251251
.. code-block:: python
252252
253253
import h2.connection
254+
import h2.config
254255
255256
def handle(sock):
256-
conn = h2.connection.H2Connection(client_side=False)
257+
config = h2.config.H2Configuration(client_side=False)
258+
conn = h2.connection.H2Connection(config=config)
257259
258260
while True:
259261
data = sock.recv(65535)
@@ -267,9 +269,11 @@ function. Your ``h2server.py`` should end up looking a like this:
267269
import socket
268270
269271
import h2.connection
272+
import h2.config
270273
271274
def handle(sock):
272-
conn = h2.connection.H2Connection(client_side=False)
275+
config = h2.config.H2Configuration(client_side=False)
276+
conn = h2.connection.H2Connection(config=config)
273277
274278
while True:
275279
data = sock.recv(65535)
@@ -331,7 +335,8 @@ function to do just that:
331335
.. code-block:: python
332336
333337
def handle(sock):
334-
conn = h2.connection.H2Connection(client_side=False)
338+
config = h2.config.H2Configuration(client_side=False)
339+
conn = h2.connection.H2Connection(config=config)
335340
conn.initiate_connection()
336341
sock.sendall(conn.data_to_send())
337342
@@ -359,9 +364,11 @@ Your ``h2server.py`` script should now look like this:
359364
import socket
360365
361366
import h2.connection
367+
import h2.config
362368
363369
def handle(sock):
364-
conn = h2.connection.H2Connection(client_side=False)
370+
config = h2.config.H2Configuration(client_side=False)
371+
conn = h2.connection.H2Connection(config=config)
365372
conn.initiate_connection()
366373
sock.sendall(conn.data_to_send())
367374
@@ -493,9 +500,11 @@ Let's amend our ``handle`` function again:
493500
.. code-block:: python
494501
495502
import h2.events
503+
import h2.config
496504
497505
def handle(sock):
498-
conn = h2.connection.H2Connection(client_side=False)
506+
config = h2.config.H2Configuration(client_side=False)
507+
conn = h2.connection.H2Connection(config=config)
499508
conn.initiate_connection()
500509
sock.sendall(conn.data_to_send())
501510
@@ -528,6 +537,7 @@ With these changes, your ``h2server.py`` file should look like this:
528537
529538
import h2.connection
530539
import h2.events
540+
import h2.config
531541
532542
def send_response(conn, event):
533543
stream_id = event.stream_id
@@ -545,7 +555,8 @@ With these changes, your ``h2server.py`` file should look like this:
545555
)
546556
547557
def handle(sock):
548-
conn = h2.connection.H2Connection(client_side=False)
558+
config = h2.config.H2Configuration(client_side=False)
559+
conn = h2.connection.H2Connection(config=config)
549560
conn.initiate_connection()
550561
sock.sendall(conn.data_to_send())
551562
@@ -633,6 +644,7 @@ file, which should now look like this:
633644
634645
import h2.connection
635646
import h2.events
647+
import h2.config
636648
637649
def send_response(conn, event):
638650
stream_id = event.stream_id
@@ -654,7 +666,8 @@ file, which should now look like this:
654666
)
655667
656668
def handle(sock):
657-
conn = h2.connection.H2Connection(client_side=False)
669+
config = h2.config.H2Configuration(client_side=False)
670+
conn = h2.connection.H2Connection(config=config)
658671
conn.initiate_connection()
659672
sock.sendall(conn.data_to_send())
660673

0 commit comments

Comments
 (0)