From fa70cf73a8cd3ba0bbd47c85091080ab2bd30e89 Mon Sep 17 00:00:00 2001 From: dosse91 Date: Mon, 7 Oct 2019 08:00:50 +0200 Subject: [PATCH] HTTP headers were accidentally case sensitive --- Speedtest-Android/app/build.gradle | 4 ++-- .../java/com/fdossena/speedtest/core/base/Connection.java | 4 ++-- .../main/java/com/fdossena/speedtest/core/getIP/GetIP.java | 3 +-- .../java/com/fdossena/speedtest/core/telemetry/Telemetry.java | 2 +- Speedtest-Android/build.gradle | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Speedtest-Android/app/build.gradle b/Speedtest-Android/app/build.gradle index f85b01b..0f5d5fb 100644 --- a/Speedtest-Android/app/build.gradle +++ b/Speedtest-Android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "your.name.here.speedtest" minSdkVersion 15 targetSdkVersion 28 - versionCode 3 - versionName '1.1.1' + versionCode 4 + versionName '1.1.2' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java index e679545..24b68e5 100644 --- a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java +++ b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/base/Connection.java @@ -21,7 +21,7 @@ public class Connection { private int mode=MODE_NOT_SET; private static final int MODE_NOT_SET=0, MODE_HTTP=1, MODE_HTTPS=2; - private static final String USER_AGENT="Speedtest-Android/1.1 (SDK "+Build.VERSION.SDK_INT+"; "+Build.PRODUCT+"; Android "+Build.VERSION.RELEASE+")", + private static final String USER_AGENT="Speedtest-Android/1.1.2 (SDK "+Build.VERSION.SDK_INT+"; "+Build.PRODUCT+"; Android "+Build.VERSION.RELEASE+")", LOCALE= Build.VERSION.SDK_INT>=21?Locale.getDefault().toLanguageTag():null; public Connection(String url, int connectTimeout, int soTimeout, int recvBuffer, int sendBuffer){ @@ -206,7 +206,7 @@ public HashMap parseResponseHeaders() throws Exception{ s=readLineUnbuffered(); if(s.trim().isEmpty()) break; if(s.contains(":")){ - ret.put(s.substring(0,s.indexOf(":")).trim(),s.substring(s.indexOf(":")+1).trim()); + ret.put(s.substring(0,s.indexOf(":")).trim().toLowerCase(),s.substring(s.indexOf(":")+1).trim()); } } return ret; diff --git a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/getIP/GetIP.java b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/getIP/GetIP.java index 5363d40..2ac2835 100644 --- a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/getIP/GetIP.java +++ b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/getIP/GetIP.java @@ -33,10 +33,9 @@ public void run(){ c.GET(s,true); HashMap h=c.parseResponseHeaders(); BufferedReader br=new BufferedReader(c.getInputStreamReader()); - char[] buf=new char[Integer.parseInt(h.get("Content-Length"))]; + char[] buf=new char[Integer.parseInt(h.get("content-length"))]; br.read(buf); String data=new String(buf); - String type=h.get("Content-Type"); onDataReceived(data); c.close(); }catch(Throwable t){ diff --git a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/telemetry/Telemetry.java b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/telemetry/Telemetry.java index c3dda1f..a1d53a8 100644 --- a/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/telemetry/Telemetry.java +++ b/Speedtest-Android/app/src/main/java/com/fdossena/speedtest/core/telemetry/Telemetry.java @@ -56,7 +56,7 @@ public void run(){ ps.flush(); HashMap h=c.parseResponseHeaders(); String data=""; - String transferEncoding=h.get("Transfer-Encoding"); + String transferEncoding=h.get("transfer-encoding"); if(transferEncoding!=null&&transferEncoding.equalsIgnoreCase("chunked")){ c.readLineUnbuffered(); } diff --git a/Speedtest-Android/build.gradle b/Speedtest-Android/build.gradle index f5fb2cc..48947c3 100644 --- a/Speedtest-Android/build.gradle +++ b/Speedtest-Android/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:3.5.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files