Blame SOURCES/0003-vCenter-fix-parsing-of-HTTP-status-string-RHBZ-18373.patch

61e9b3
From bb94c68c521aa546d3f2e59aa25e388bfd9c5fc5 Mon Sep 17 00:00:00 2001
61e9b3
From: Pino Toscano <ptoscano@redhat.com>
61e9b3
Date: Tue, 19 May 2020 12:14:18 +0200
61e9b3
Subject: [PATCH] vCenter: fix parsing of HTTP status string (RHBZ#1837328)
61e9b3
61e9b3
vCenter 7 answers with an HTTP/2 status string, so we cannot extract
61e9b3
the status code from it by using fixed positions in that string.
61e9b3
Hence, pick the status code by reading what's after the whitespace.
61e9b3
61e9b3
Tested with vCenter 6.5 and 7.
61e9b3
61e9b3
(cherry picked from commit d2aa82317964d62fcc8dc7b6737773003d04b998)
61e9b3
---
61e9b3
 v2v/vCenter.ml | 4 +++-
61e9b3
 1 file changed, 3 insertions(+), 1 deletion(-)
61e9b3
61e9b3
diff --git a/v2v/vCenter.ml b/v2v/vCenter.ml
61e9b3
index c28a4ced..4c128b0c 100644
61e9b3
--- a/v2v/vCenter.ml
61e9b3
+++ b/v2v/vCenter.ml
61e9b3
@@ -190,7 +190,9 @@ and fetch_headers_from_url password_file uri sslverify https_url =
61e9b3
     | [] ->
61e9b3
        dump_response stderr;
61e9b3
        error (f_"vcenter: no status code in output of ‘curl’ command.  Is ‘curl’ installed?")
61e9b3
-    | ss -> String.sub (List.hd (List.rev ss)) 9 3 in
61e9b3
+    | ss ->
61e9b3
+      let s = List.hd (List.rev ss) in
61e9b3
+      String.sub s (String.index s ' ' + 1) 3 in
61e9b3
 
61e9b3
   let headers =
61e9b3
     List.map (
61e9b3
-- 
61e9b3
2.27.0
61e9b3