Skip to content

Commit be2f9bf

Browse files
committed
make server slow to respond, to be able to test proxy parallelism
1 parent d056637 commit be2f9bf

File tree

1 file changed

+7
-1
lines changed
  • 03_networks/03_web_protocols/http_proxy/server

1 file changed

+7
-1
lines changed

03_networks/03_web_protocols/http_proxy/server/server.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import http.server
33
import json
4+
import time
45
from socketserver import ThreadingMixIn
56

67

@@ -14,7 +15,12 @@ def do_GET(self):
1415
body = json.dumps(dict(self.headers), indent=4).encode('utf8')
1516
self.send_header('Content-Length', str(len(body)))
1617
self.end_headers()
17-
self.wfile.write(body)
18+
i = 0
19+
step = 20
20+
while i < len(body):
21+
self.wfile.write(body[i:i+step])
22+
time.sleep(0.1)
23+
i += step
1824

1925
do_POST = do_GET
2026

0 commit comments

Comments
 (0)