(s)
| 108 | s.sendheaders([("Access-Control-Allow-Headers", "Range")], 0) |
| 109 | |
| 110 | def do_GET(s): |
| 111 | # CORS preflight makes OPTIONS requests which we need to account for. |
| 112 | expectedConns = 22 |
| 113 | s.num_get_connections += 1 |
| 114 | assert s.num_get_connections < expectedConns |
| 115 | |
| 116 | if s.path == '/': |
| 117 | s.sendheaders() |
| 118 | elif not support_byte_ranges: |
| 119 | s.sendheaders() |
| 120 | s.wfile.write(data) |
| 121 | else: |
| 122 | start, end = s.headers.get("range").split("=")[1].split("-") |
| 123 | start = int(start) |
| 124 | end = int(end) |
| 125 | end = min(len(data) - 1, end) |
| 126 | length = end - start + 1 |
| 127 | s.sendheaders([], length) |
| 128 | s.wfile.write(data[start:end + 1]) |
| 129 | |
| 130 | return HTTPServer(('localhost', 11111), ChunkedServerHandler) |
| 131 |
nothing calls this directly
no test coverage detected