>From 6eb473a7e67de82bf08b97f2610ee3364071c741 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 15 Oct 2018 16:07:52 +0100 Subject: [PATCH] v2v: -o rhv-upload: Test using HTTP/1.1 protocol. Fixes commit b54b58c44e3f1f54a05117c758eaa21d9f1085f0. Thanks: Nir Soffer. --- .../ovirtsdk4/__init__.py | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py b/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py index b5f739471..84b9d56aa 100644 --- a/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py +++ b/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py @@ -116,24 +116,44 @@ from http.server import HTTPServer, BaseHTTPRequestHandler import threading class RequestHandler(BaseHTTPRequestHandler): + protocol_version = 'HTTP/1.1' + def do_OPTIONS(self): - self.send_response(200) - self.send_header("Content-type", "application/json; charset=UTF-8") - self.end_headers() + self.discard_request() + # Advertize only zero support. - self.wfile.write(b'''{ "features": [ "zero" ] }''') + content = b'''{ "features": [ "zero" ] }''' + length = len(content) + + self.send_response(200) + self.send_header("Content-type", "application/json; charset=UTF-8") + self.send_header("Content-Length", length) + self.end_headers() + self.wfile.write(content) # eg. zero request. Just ignore it. def do_PATCH(self): + self.discard_request() self.send_response(200) + self.send_header("Content-Length", "0") self.end_headers() # Flush request. Ignore it. def do_PUT(self): + self.discard_request() self.send_response(200) + self.send_header("Content-Length", "0") self.end_headers() + def discard_request(self): + length = self.headers['Content-Length'] + if length: + length = int(length) + content = self.rfile.read(length) + server_address = ("", 0) +# XXX This should test HTTPS, not HTTP, because we are testing a +# different path through the main code. httpd = HTTPServer(server_address, RequestHandler) imageio_port = httpd.server_address[1] -- 2.19.0.rc0