Skip to content

Commit

Permalink
HTTP headers were accidentally case sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfintel committed Oct 7, 2019
1 parent 89a1b0b commit fa70cf7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Speedtest-Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -206,7 +206,7 @@ public HashMap<String, String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ public void run(){
c.GET(s,true);
HashMap<String,String> 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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void run(){
ps.flush();
HashMap<String,String> 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();
}
Expand Down
2 changes: 1 addition & 1 deletion Speedtest-Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fa70cf7

Please sign in to comment.