in http/get_multipart/python/server/server.py [0:0]
def do_GET(self):
### note: always use urlparse in your applications.
self._include_footnotes = self.path.endswith("?include_footnotes")
### in a real application the data would be resolved from a database or
### another source like a file and error handling would be done here
### before the 200 OK response starts being sent to the client.
json_data_header = self._resolve_json_data_header()
source = self._resolve_batches()
if self.request_version == "HTTP/1.0":
self.protocol_version = "HTTP/1.0"
chunked = False
else:
self.protocol_version = "HTTP/1.1"
chunked = CHUNKED_ENCODING
self.send_response(200)
boundary = random_multipart_boundary()
self.send_header("Content-Type", f"multipart/mixed; boundary={boundary}")
### set these headers if testing with a local browser-based client:
# self.send_header('Access-Control-Allow-Origin', 'http://localhost:8008')
# self.send_header('Access-Control-Allow-Methods', 'GET')
# self.send_header('Access-Control-Allow-Headers', 'Content-Type')
if chunked:
self.send_header("Transfer-Encoding", "chunked")
self.end_headers()
for buffer in self._gen_buffers(boundary, json_data_header, the_schema, source):
if chunked:
self.wfile.write(f"{len(buffer):X}\r\n".encode("utf-8"))
self.wfile.write(buffer)
if chunked:
self.wfile.write("\r\n".encode("utf-8"))
self.wfile.flush()
if chunked:
self.wfile.write("0\r\n\r\n".encode("utf-8"))
self.wfile.flush()