Skip to content

Commit

Permalink
Merge pull request signalapp#1887 from mcginty/mms-3xx
Browse files Browse the repository at this point in the history
allow url client to follow redirects before checking response code
  • Loading branch information
moxie0 committed Aug 29, 2014
2 parents 102b405 + eb462f0 commit 877f2a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/org/thoughtcrime/securesms/mms/MmsCommunication.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ protected static HttpURLConnection constructHttpClient(String urlString, String
urlConnection = (HttpURLConnection) url.openConnection();
}

urlConnection.setInstanceFollowRedirects(true);
urlConnection.setConnectTimeout(20*1000);
urlConnection.setReadTimeout(20*1000);
urlConnection.setUseCaches(false);
Expand Down
6 changes: 4 additions & 2 deletions src/org/thoughtcrime/securesms/mms/MmsDownloadHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.util.Arrays;

Expand All @@ -45,15 +46,16 @@ private static byte[] makeRequest(String url, String proxy, int proxyPort)
Log.w(TAG, "Connecting to " + url);
client.connect();

int responseCode = client.getResponseCode();
final InputStream is = client.getInputStream();
final int responseCode = client.getResponseCode();

Log.w(TAG, "Response code: " + responseCode + "/" + client.getResponseMessage());

if (responseCode != 200) {
throw new IOException("non-200 response");
}

return parseResponse(client.getInputStream());
return parseResponse(is);
} finally {
if (client != null) client.disconnect();
}
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/mms/MmsSendHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ private static byte[] makePost(String url, String proxy, int proxyPort, byte[] m

Log.w(TAG, "Payload sent");

int responseCode = client.getResponseCode();
final InputStream is = client.getInputStream();
final int responseCode = client.getResponseCode();

Log.w(TAG, "Response code: " + responseCode + "/" + client.getResponseMessage());

if (responseCode != 200) {
throw new IOException("non-200 response");
}

return parseResponse(client.getInputStream());
return parseResponse(is);
} finally {
if (client != null) client.disconnect();
}
Expand Down

0 comments on commit 877f2a2

Please sign in to comment.