v2v: -o rhv-upload: Fix test so it doesn't fail if Content-Length header missing.

If the Content-Length header was missing from the headers returned by
the server then the test would fail with:

KeyError: 'content-length'

This happens on RHEL 7.6 in particular.  We can fix this by using an
alternate method to fetch the header, which will return None instead
of throwing an exception if the header doesn't exist.  See:
https://stackoverflow.com/a/19255675
This commit is contained in:
Richard W.M. Jones
2018-11-20 17:00:33 +00:00
parent a4f83ee6a4
commit 724d7877f8

View File

@@ -146,7 +146,7 @@ class RequestHandler(BaseHTTPRequestHandler):
self.end_headers()
def discard_request(self):
length = self.headers['Content-Length']
length = self.headers.get('Content-Length')
if length:
length = int(length)
content = self.rfile.read(length)