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);
|
||||
proxy = null;
|
||||
if( proxyEnabled ){
|
||||
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
||||
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
||||
if( type == 0 )
|
||||
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
||||
else
|
||||
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(host, port));
|
||||
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
|
||||
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
|
||||
if( login != null) {
|
||||
Authenticator authenticator = new Authenticator() {
|
||||
public PasswordAuthentication getPasswordAuthentication() {
|
||||
assert pwd != null;
|
||||
return (new PasswordAuthentication(login,
|
||||
pwd.toCharArray()));
|
||||
}
|
||||
};
|
||||
Authenticator.setDefault(authenticator);
|
||||
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 )
|
||||
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
||||
else
|
||||
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(host, port));
|
||||
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
|
||||
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
|
||||
if( login != null) {
|
||||
Authenticator authenticator = new Authenticator() {
|
||||
public PasswordAuthentication getPasswordAuthentication() {
|
||||
assert pwd != null;
|
||||
return (new PasswordAuthentication(login,
|
||||
pwd.toCharArray()));
|
||||
}
|
||||
};
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue