cros_sdk: fix more quirks and corner cases in parsing curl HTTP responses
See section 3.1 here:
https://www.ietf.org/rfc/rfc2616.txt
that says:
"""
The version of an HTTP message is indicated by an HTTP-Version field
in the first line of the message.
HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT
"""
However, we've seen reports in the wild of (potentially non-conforming?)
HTTP/2 implementations returning 'HTTP/2 200 OK'. Rather than being
unnecessarily pedantic here, let's just accept the not-so-standard
format.
While we're at it, I noticed that the HTTP standard allows for these
major/minor revisions to roll over to 2+ digits.
And finally, note that '.' is a regex wildcard. Let's escape it
properly.
So, a few representative examples of prefixes we accept:
'HTTP/1.0 200'
'HTTP/1.1 200'
'HTTP/1 200'
'HTTP/2.0 200'
'HTTP/2 200'
'HTTP/99999 200'
'HTTP/1337.987654321 200'
But we no longer allow:
'HTTP/1a0 200'
BUG=chromium:541462, chromium:810207
TEST=trybots; download a new checkout / build the cros_sdk chroot
Change-Id: I804a0bd13f50ddaec1f6a6b7fe0fd16f5aa9167d
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/389815
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Dan Erat <derat@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/957714
Commit-Queue: Alexandru M Stan <amstan@chromium.org>
Tested-by: Alexandru M Stan <amstan@chromium.org>
Trybot-Ready: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1139712
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index 0f097f5..2fbcad9 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -86,7 +86,7 @@
# fail if asked to resume a complete file.
# pylint: disable=C0301,W0631
# https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3482927&group_id=976
- status_re = re.compile(r'^HTTP/[0-9].[0-9] 200')
+ status_re = re.compile(r'^HTTP/[0-9]+(\.[0-9]+)? 200')
for url in urls:
# http://www.logilab.org/ticket/8766
# pylint: disable=E1101