Skip to content

Commit

Permalink
Unit tests: linkcheck: send Content-Length header in all HTTP/1.1 tes…
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Apr 21, 2023
1 parent 88fb703 commit 2cad628
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_build_linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ class DefaultsHandler(http.server.BaseHTTPRequestHandler):
def do_HEAD(self):
if self.path[1:].rstrip() == "": # noqa: SIM114
self.send_response(200, "OK")
self.send_header("Content-Length", "0")
self.end_headers()
elif self.path[1:].rstrip() == "anchor.html":
self.send_response(200, "OK")
self.send_header("Content-Length", "0")
self.end_headers()
else:
self.send_response(404, "Not Found")
self.send_header("Content-Length", "0")
self.end_headers()

def do_GET(self):
Expand All @@ -57,6 +60,7 @@ def do_GET(self):
self.wfile.write(content)
else:
self.send_response(404, "Not Found")
self.send_header("Content-Length", "0")
self.end_headers()


Expand Down Expand Up @@ -254,6 +258,7 @@ def do_HEAD(self):
def do_GET(self):
records.append(self.headers.as_string())
self.send_response(200, "OK")
self.send_header("Content-Length", "0")
self.end_headers()
return HeadersDumperHandler

Expand Down Expand Up @@ -356,6 +361,7 @@ def do_HEAD(self):
def do_GET(self):
if self.path == "/?redirected=1":
self.send_response(204, "No content")
self.send_header("Content-Length", "0")
else:
self.send_response(302, "Found")
self.send_header("Location", "http://localhost:7777/?redirected=1")
Expand Down Expand Up @@ -441,6 +447,7 @@ class OKHandler(http.server.BaseHTTPRequestHandler):

def do_HEAD(self):
self.send_response(200, "OK")
self.send_header("Content-Length", "0")
self.end_headers()

def do_GET(self):
Expand Down Expand Up @@ -557,6 +564,7 @@ class InfiniteRedirectOnHeadHandler(http.server.BaseHTTPRequestHandler):
def do_HEAD(self):
self.send_response(302, "Found")
self.send_header("Location", "http://localhost:7777/")
self.send_header("Content-Length", "0")
self.end_headers()

def do_GET(self):
Expand Down Expand Up @@ -597,6 +605,7 @@ def do_HEAD(self):
self.send_response(status)
if retry_after:
self.send_header('Retry-After', retry_after)
self.send_header("Content-Length", "0")
self.end_headers()

def log_date_time_string(self):
Expand Down Expand Up @@ -750,6 +759,7 @@ def do_HEAD(self):

def do_GET(self):
self.send_response(200, "OK")
self.send_header("Content-Length", "0")
self.end_headers()


Expand Down

0 comments on commit 2cad628

Please sign in to comment.