mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-26 01:06:34 +00:00
Add a new connection error type & fix periodic sync
This commit is contained in:
parent
56857c16d4
commit
d12bd8b835
@ -151,6 +151,7 @@ public class OCHttpClient {
|
||||
public Pair<Integer, JSONObject> execute(String method, URL url, String requestBody, boolean skipError) throws OCSyncException {
|
||||
Pair<Integer, JSONObject> response;
|
||||
HttpURLConnection urlConnection = null;
|
||||
|
||||
try {
|
||||
urlConnection = (HttpURLConnection) url.openConnection();
|
||||
} catch (IOException e) {
|
||||
@ -171,7 +172,7 @@ public class OCHttpClient {
|
||||
urlConnection.setRequestMethod(method);
|
||||
} catch (ProtocolException e) {
|
||||
Log.e(OCHttpClient.TAG, "Fatal error when setting request method: " + e);
|
||||
throw new OCSyncException(R.string.err_sync_http_request_ioexception, OCSyncErrorType.IO);
|
||||
throw new OCSyncException(R.string.err_sync_http_request_protocol_exception, OCSyncErrorType.IO);
|
||||
}
|
||||
urlConnection.setRequestProperty("User-Agent", _userAgent);
|
||||
urlConnection.setInstanceFollowRedirects(true);
|
||||
@ -180,8 +181,9 @@ public class OCHttpClient {
|
||||
}
|
||||
urlConnection.setRequestProperty("Content-Type", "application/json");
|
||||
urlConnection.setRequestProperty("Accept", "application/json");
|
||||
urlConnection.setRequestProperty("Transfer-Encoding", "chunked");
|
||||
|
||||
if (!"GET".equals(method)) {
|
||||
urlConnection.setRequestProperty("Transfer-Encoding", "chunked");
|
||||
}
|
||||
String basicAuth = "Basic " +
|
||||
Base64.encodeToString((_username + ":" + _password).getBytes(), Base64.NO_WRAP);
|
||||
urlConnection.setRequestProperty("Authorization", basicAuth);
|
||||
|
@ -273,4 +273,5 @@
|
||||
<string name="pref_show_sync_notifications">Show sync notifications</string>
|
||||
<string name="sync_complete">Synchronization complete</string>
|
||||
<string name="err_sync_http_write_failed">Error #19: Failed to write HTTP stream when pushing data to server.</string>
|
||||
<string name="err_sync_http_request_protocol_exception">Error #20: Failed to properly set HTTP protocol version.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user