Merge "CaptivePortalLoginActivity correctly gets UserAgent" am: 4903487fd9 am: 43961ee6ae
am: 4f9e934c5f
Change-Id: I234d55c758c7538717d27035fdc8864a8650d75c
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index 23a8655..6394c64 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -77,8 +77,8 @@
mCm = ConnectivityManager.from(this);
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
- mUserAgent = getIntent().getParcelableExtra(
- ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
+ mUserAgent =
+ getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
mUrl = getUrl();
if (mUrl == null) {
// getUrl() failed to parse the url provided in the intent: bail out in a way that
@@ -274,8 +274,17 @@
if (mUserAgent != null) {
urlConnection.setRequestProperty("User-Agent", mUserAgent);
}
+ // cannot read request header after connection
+ String requestHeader = urlConnection.getRequestProperties().toString();
+
urlConnection.getInputStream();
httpResponseCode = urlConnection.getResponseCode();
+ if (DBG) {
+ Log.d(TAG, "probe at " + mUrl +
+ " ret=" + httpResponseCode +
+ " request=" + requestHeader +
+ " headers=" + urlConnection.getHeaderFields());
+ }
} catch (IOException e) {
} finally {
if (urlConnection != null) urlConnection.disconnect();
diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
index fbda901..cf33313 100644
--- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java
+++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
@@ -790,6 +790,8 @@
if (userAgent != null) {
urlConnection.setRequestProperty("User-Agent", userAgent);
}
+ // cannot read request header after connection
+ String requestHeader = urlConnection.getRequestProperties().toString();
// Time how long it takes to get a response to our request
long requestTimestamp = SystemClock.elapsedRealtime();
@@ -803,6 +805,7 @@
validationLog(ValidationProbeEvent.getProbeName(probeType) + " " + url +
" time=" + (responseTimestamp - requestTimestamp) + "ms" +
" ret=" + httpResponseCode +
+ " request=" + requestHeader +
" headers=" + urlConnection.getHeaderFields());
// NOTE: We may want to consider an "HTTP/1.0 204" response to be a captive
// portal. The only example of this seen so far was a captive portal. For