MCPcopy Create free account
hub / github.com/Kaggle/docker-python / HTTPHandler

Class HTTPHandler

tests/test_bigquery_proxy.py:21–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20 def _test_proxy(self, client):
21 class HTTPHandler(BaseHTTPRequestHandler):
22 called = False
23 proxy_header_found = False
24
25 def do_HEAD(self):
26 self.send_response(200)
27
28 def do_GET(self):
29 HTTPHandler.called = True
30 HTTPHandler.proxy_header_found = any(
31 k for k in self.headers if k == "X-KAGGLE-PROXY-DATA" and self.headers[k] == "test-key")
32 self.send_response(200)
33 self.send_header("Content-type", "application/json")
34 self.end_headers()
35 sample_dataset = {
36 "id": "bigqueryproject:datasetname",
37 "datasetReference": {
38 "datasetId": "datasetname",
39 "projectId": "bigqueryproject"
40 }
41 }
42 self.wfile.write(json.dumps({"kind": "bigquery#datasetList", "datasets": [sample_dataset]}).encode("utf-8"))
43
44 server_address = urlparse(os.getenv('KAGGLE_DATA_PROXY_URL'))
45 with HTTPServer((server_address.hostname, server_address.port), HTTPHandler) as httpd:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected