Fixes Pleroma upload issue

This commit is contained in:
stom79 2018-08-30 17:48:32 +02:00
parent 46b07ea255
commit b103f661a9
1 changed files with 28 additions and 21 deletions

View File

@ -88,6 +88,7 @@ public class HttpsConnection {
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
proxy = null;
if( proxyEnabled ){
try {
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
if( type == 0 )
@ -106,6 +107,10 @@ public class HttpsConnection {
};
Authenticator.setDefault(authenticator);
}
}catch (Exception e){
proxy = null;
}
}
}
@ -1075,7 +1080,8 @@ public class HttpsConnection {
byte[] pixels = ous.toByteArray();
int lengthSent = pixels.length;
lengthSent += 2 * (twoHyphens + boundary + twoHyphens + lineEnd).getBytes().length;
lengthSent += (twoHyphens + boundary + lineEnd).getBytes().length;
lengthSent += (twoHyphens + boundary + twoHyphens +lineEnd).getBytes().length;
lengthSent += ("Content-Disposition: form-data; name=\"file\"; filename=\""+fileName+"\"" + lineEnd).getBytes().length;
lengthSent += 2 * (lineEnd).getBytes().length;
@ -1102,7 +1108,7 @@ public class HttpsConnection {
DataOutputStream request = new DataOutputStream(httpsURLConnection.getOutputStream());
request.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
request.writeBytes(twoHyphens + boundary + lineEnd);
request.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\""+fileName+"\"" + lineEnd);
request.writeBytes(lineEnd);
@ -1233,7 +1239,8 @@ public class HttpsConnection {
byte[] pixels = ous.toByteArray();
int lengthSent = pixels.length;
lengthSent += 2 * (twoHyphens + boundary + twoHyphens + lineEnd).getBytes().length;
lengthSent += (twoHyphens + boundary + lineEnd).getBytes().length;
lengthSent += (twoHyphens + boundary + twoHyphens +lineEnd).getBytes().length;
lengthSent += ("Content-Disposition: form-data; name=\"file\";filename=\""+fileName+"\"" + lineEnd).getBytes().length;
lengthSent += 2 * (lineEnd).getBytes().length;
@ -1259,7 +1266,7 @@ public class HttpsConnection {
DataOutputStream request = new DataOutputStream(httpURLConnection.getOutputStream());
request.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
request.writeBytes(twoHyphens + boundary + lineEnd);
request.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\""+fileName+"\"" + lineEnd);
request.writeBytes(lineEnd);