Fixes Pleroma upload issue
This commit is contained in:
parent
46b07ea255
commit
b103f661a9
|
@ -88,24 +88,29 @@ public class HttpsConnection {
|
||||||
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
||||||
proxy = null;
|
proxy = null;
|
||||||
if( proxyEnabled ){
|
if( proxyEnabled ){
|
||||||
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
try {
|
||||||
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
||||||
if( type == 0 )
|
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
||||||
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
if( type == 0 )
|
||||||
else
|
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
||||||
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(host, port));
|
else
|
||||||
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
|
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(host, port));
|
||||||
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
|
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
|
||||||
if( login != null) {
|
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
|
||||||
Authenticator authenticator = new Authenticator() {
|
if( login != null) {
|
||||||
public PasswordAuthentication getPasswordAuthentication() {
|
Authenticator authenticator = new Authenticator() {
|
||||||
assert pwd != null;
|
public PasswordAuthentication getPasswordAuthentication() {
|
||||||
return (new PasswordAuthentication(login,
|
assert pwd != null;
|
||||||
pwd.toCharArray()));
|
return (new PasswordAuthentication(login,
|
||||||
}
|
pwd.toCharArray()));
|
||||||
};
|
}
|
||||||
Authenticator.setDefault(authenticator);
|
};
|
||||||
|
Authenticator.setDefault(authenticator);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
proxy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,7 +1080,8 @@ public class HttpsConnection {
|
||||||
byte[] pixels = ous.toByteArray();
|
byte[] pixels = ous.toByteArray();
|
||||||
|
|
||||||
int lengthSent = pixels.length;
|
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 += ("Content-Disposition: form-data; name=\"file\"; filename=\""+fileName+"\"" + lineEnd).getBytes().length;
|
||||||
lengthSent += 2 * (lineEnd).getBytes().length;
|
lengthSent += 2 * (lineEnd).getBytes().length;
|
||||||
|
|
||||||
|
@ -1102,7 +1108,7 @@ public class HttpsConnection {
|
||||||
|
|
||||||
DataOutputStream request = new DataOutputStream(httpsURLConnection.getOutputStream());
|
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("Content-Disposition: form-data; name=\"file\"; filename=\""+fileName+"\"" + lineEnd);
|
||||||
request.writeBytes(lineEnd);
|
request.writeBytes(lineEnd);
|
||||||
|
|
||||||
|
@ -1233,7 +1239,8 @@ public class HttpsConnection {
|
||||||
byte[] pixels = ous.toByteArray();
|
byte[] pixels = ous.toByteArray();
|
||||||
|
|
||||||
int lengthSent = pixels.length;
|
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 += ("Content-Disposition: form-data; name=\"file\";filename=\""+fileName+"\"" + lineEnd).getBytes().length;
|
||||||
lengthSent += 2 * (lineEnd).getBytes().length;
|
lengthSent += 2 * (lineEnd).getBytes().length;
|
||||||
|
|
||||||
|
@ -1259,7 +1266,7 @@ public class HttpsConnection {
|
||||||
|
|
||||||
DataOutputStream request = new DataOutputStream(httpURLConnection.getOutputStream());
|
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("Content-Disposition: form-data; name=\"file\";filename=\""+fileName+"\"" + lineEnd);
|
||||||
request.writeBytes(lineEnd);
|
request.writeBytes(lineEnd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue