OSDN Git Service

Captive portal: better detect empty responses
authorHugo Benichi <hugobenichi@google.com>
Wed, 11 Jan 2017 07:23:26 +0000 (16:23 +0900)
committerHugo Benichi <hugobenichi@google.com>
Thu, 12 Jan 2017 06:21:35 +0000 (15:21 +0900)
commitcb4aa4d412c7940386df9b8dd681e0d2efebfd1d
treecaa5bae5744ad41f19711a93cecaa5c9b68a9390
parenta00c2356009e1f93c1f86974048e49b69e4ab7a4
Captive portal: better detect empty responses

The captive portal detection logic treats empty http responses with a
Content-Length of 0 as not coming from a portal.

However when the Content-Length is missing from the response header, the
empty response is not detected as such and is classified as a captive
portal answer.

When this happens for the http probe, the portal detection logic will
short circuit the detection and wrongly report a portal. The system
validates the network in such conditions only if the https probe
returns a successful connection faster than the http probe.

This patch attempts to better detect empty responses by trying to read
the first byte from the response body when the Content-Length is missing
for 200 responses.

Test: build, flashed + manual tests.
Bug: 33498325
Change-Id: Ie2e5c6a9dc3740e4a2304034879b5ed60f277ade
services/core/java/com/android/server/connectivity/NetworkMonitor.java