cros_sdk: fix more quirks and corner cases in parsing curl HTTP responses

See section 3.1 here:

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

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

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 <>
Reviewed-by: Daniel Stone <>
Reviewed-by: Dan Erat <>
Reviewed-by: Mike Frysinger <>
Commit-Queue: Alexandru M Stan <>
Tested-by: Alexandru M Stan <>
Trybot-Ready: Alexandru M Stan <>
Tested-by: Mike Frysinger <>
1 file changed