diff options
| author | 2019-02-20 11:14:24 +0000 | |
|---|---|---|
| committer | 2019-02-20 11:14:24 +0000 | |
| commit | 1d18e60e76bed90e6b00d17df79f63d0bb7b0443 (patch) | |
| tree | 2b71c6e37c071c64da19c90dfe8b6dc480977c2a | |
| parent | f2cf09c94510857f99fd94381d609784dd46b334 (diff) | |
| parent | 8e9a15bdbd938b24d57c17139ed9b5eadedc37d2 (diff) | |
Merge "Consider 200 response with "Content-length <= 4" to not be a captive portal."
| -rw-r--r-- | packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java index ec4a47930fad..4b846b0fb372 100644 --- a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java +++ b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java @@ -1318,26 +1318,28 @@ public class NetworkMonitor extends StateMachine { // is needed (i.e. can't browse a 204). This could be the result of an HTTP // proxy server. if (httpResponseCode == 200) { + long contentLength = urlConnection.getContentLengthLong(); if (probeType == ValidationProbeEvent.PROBE_PAC) { validationLog( probeType, url, "PAC fetch 200 response interpreted as 204 response."); httpResponseCode = CaptivePortalProbeResult.SUCCESS_CODE; - } else if (urlConnection.getContentLengthLong() == 0) { - // Consider 200 response with "Content-length=0" to not be a captive portal. - // There's no point in considering this a captive portal as the user cannot - // sign-in to an empty page. Probably the result of a broken transparent proxy. - // See http://b/9972012. - validationLog(probeType, url, - "200 response with Content-length=0 interpreted as 204 response."); - httpResponseCode = CaptivePortalProbeResult.SUCCESS_CODE; - } else if (urlConnection.getContentLengthLong() == -1) { - // When no Content-length (default value == -1), attempt to read a byte from the - // response. Do not use available() as it is unreliable. See http://b/33498325. + } else if (contentLength == -1) { + // When no Content-length (default value == -1), attempt to read a byte + // from the response. Do not use available() as it is unreliable. + // See http://b/33498325. if (urlConnection.getInputStream().read() == -1) { - validationLog( - probeType, url, "Empty 200 response interpreted as 204 response."); - httpResponseCode = CaptivePortalProbeResult.SUCCESS_CODE; + validationLog(probeType, url, + "Empty 200 response interpreted as failed response."); + httpResponseCode = CaptivePortalProbeResult.FAILED_CODE; } + } else if (contentLength <= 4) { + // Consider 200 response with "Content-length <= 4" to not be a captive + // portal. There's no point in considering this a captive portal as the + // user cannot sign-in to an empty page. Probably the result of a broken + // transparent proxy. See http://b/9972012 and http://b/122999481. + validationLog(probeType, url, "200 response with Content-length <= 4" + + " interpreted as failed response."); + httpResponseCode = CaptivePortalProbeResult.FAILED_CODE; } } } catch (IOException e) { |