Skip to content
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

Specify keep-alive in exercise 1-6 #1377

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 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 @@ -842,6 +844,7 @@ Next, we'll wrap the socket with the `ssl` library:
class URL:
def request(self):
# ...
s.connect((self.host, self.port))
if self.scheme == "https":
ctx = ssl.create_default_context()
s = ctx.wrap_socket(s, server_hostname=self.host)
Expand Down Expand Up @@ -981,7 +984,8 @@ print the entire HTML file as if it was text. You'll want to have also
implemented Exercise 1-4.

1-6 *Keep-alive*. Implement Exercise 1-1; however, do not send
the `Connection: close` header. Instead, when reading the body from
the `Connection: close` header (send `Connection: keep-alive` instead).
Instead, when reading the body from
the socket, only read as many bytes as given in the `Content-Length`
header and don't close the socket afterward. Instead, save the
socket, and if another request is made to the same server reuse the
Expand Down
2 changes: 1 addition & 1 deletion book/outline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ WIDTH, HEIGHT
HSTEP, VSTEP
class Rect:
def __init__(left, top, right, bottom)
def containsPoint(x, y)
def contains_point(x, y)
INPUT_WIDTH_PX
IFRAME_WIDTH_PX, IFRAME_HEIGHT_PX
BLOCK_ELEMENTS
Expand Down
1 change: 1 addition & 0 deletions infra/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def set_status(self, i, status):
for d in self.data:
if d['name'] == self.data[i]['name']:
d['status'] = 'denied'
self.save()
return
self.data[i]['status'] = status
self.save()
Expand Down
Loading