cros_sdk: improve curl output parsing

Derived from CoreOS commit add4c2e24ca7e23bb3895fdea8fa58eab950f9dc
https://github.com/coreos/chromite/pull/21

    """
    Blindly searching for '200 OK' doesn't work with HTTP/2 which doesn't
    include a text description in the response. Match the status line by
    prefix instead. Seems less foolish anyway.
    """

Might as well future-proof against HTTP revisions up to 9.9 ;)

BUG=chromium:541462
TEST=`cros_sdk`; set up new chroot; trybots

Change-Id: I5e88a4b38f357bb08449de302a5c813f572136d2
(cherry picked from commit d37e2f74eb684ff97f566ca3ca85daf20a1938df)
Reviewed-on: https://chromium-review.googlesource.com/1139635
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index c0618e9..ad6ea46 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -9,6 +9,7 @@
 import glob
 import os
 import pwd
+import re
 import sys
 import urlparse
 
@@ -85,6 +86,7 @@
   # pylint: disable=C0301,W0631
   # https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3482927&group_id=976
   logging.notice('Downloading chroot files.')
+  status_re = re.compile(r'^HTTP/[0-9].[0-9] 200')
   for url in urls:
     # http://www.logilab.org/ticket/8766
     # pylint: disable=E1101
@@ -101,9 +103,9 @@
         redirect_stderr=True, print_cmd=False, debug_level=logging.NOTICE)
     successful = False
     for header in result.output.splitlines():
-      # We must walk the output to find the string '200 OK' for use cases where
+      # We must walk the output to find the 200 code for use cases where
       # a proxy is involved and may have pushed down the actual header.
-      if header.find('200 OK') != -1:
+      if status_re.match(header):
         successful = True
       elif header.lower().startswith('content-length:'):
         content_length = int(header.split(':', 1)[-1].strip())