From 7f545f1feabcb30fa0ccb3cab3f46392d01f0fea Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 19 Apr 2023 15:02:55 -0400 Subject: [PATCH] 20257: Need to parse status code out of the header, because pyCurl Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- sdk/python/arvados/http_import.py | 5 ++++- sdk/python/tests/test_http.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sdk/python/arvados/http_import.py b/sdk/python/arvados/http_import.py index d45eb7b633..f4913a5b74 100644 --- a/sdk/python/arvados/http_import.py +++ b/sdk/python/arvados/http_import.py @@ -173,7 +173,10 @@ class CurlDownloader(PyCurlHelper): else: self.name = self.parsedurl.path.split("/")[-1] - if self.curl.getinfo(pycurl.RESPONSE_CODE) == 200: + mt = re.match(r'^HTTP\/(\d(\.\d)?) ([1-5]\d\d) ([^\r\n\x00-\x08\x0b\x0c\x0e-\x1f\x7f]*)\r\n$', self._headers["x-status-line"]) + code = int(mt.group(3)) + + if code == 200: self.target = self.collection.open(self.name, "wb") def body_write(self, chunk): diff --git a/sdk/python/tests/test_http.py b/sdk/python/tests/test_http.py index 44d0d2599a..fa61e9ed8b 100644 --- a/sdk/python/tests/test_http.py +++ b/sdk/python/tests/test_http.py @@ -59,6 +59,11 @@ class CurlMock: def perform(self): self.perform_was_called = True + if self.head: + self.headerfn("HTTP/1.1 {} Status".format(self.head_response)) + else: + self.headerfn("HTTP/1.1 {} Status".format(self.get_response)) + for k,v in self.headers.items(): self.headerfn("%s: %s" % (k,v)) -- 2.30.2