@@ -59,6 +59,7 @@ public class OwnCloudClient extends HttpClient {
59
59
public static final String STATUS_PATH = "/status.php" ;
60
60
private static final String WEBDAV_UPLOADS_PATH_4_0 = "/remote.php/dav/uploads/" ;
61
61
private static final int MAX_REDIRECTIONS_COUNT = 5 ;
62
+ private static final int MAX_RETRY_COUNT = 2 ;
62
63
63
64
private static int sIntanceCounter = 0 ;
64
65
private OwnCloudCredentials mCredentials = null ;
@@ -112,12 +113,12 @@ public int executeHttpMethod(HttpBaseMethod method) throws Exception {
112
113
}
113
114
114
115
private int saveExecuteHttpMethod (HttpBaseMethod method ) throws Exception {
115
- boolean repeatWithFreshCredentials ;
116
116
int repeatCounter = 0 ;
117
117
int status ;
118
118
119
- boolean retry = false ;
119
+ boolean retry ;
120
120
do {
121
+ repeatCounter ++;
121
122
retry = false ;
122
123
String requestId = RandomUtils .generateRandomUUID ();
123
124
@@ -126,7 +127,7 @@ private int saveExecuteHttpMethod(HttpBaseMethod method) throws Exception {
126
127
method .setRequestHeader (HttpConstants .OC_X_REQUEST_ID , requestId );
127
128
method .setRequestHeader (HttpConstants .USER_AGENT_HEADER , SingleSessionManager .getUserAgent ());
128
129
method .setRequestHeader (HttpConstants .ACCEPT_ENCODING_HEADER , HttpConstants .ACCEPT_ENCODING_IDENTITY );
129
- if (mCredentials .getHeaderAuth () != null && method . getRequestHeader ( AUTHORIZATION_HEADER ) == null ) {
130
+ if (mCredentials .getHeaderAuth () != null && ! mCredentials . getHeaderAuth (). isEmpty () ) {
130
131
method .setRequestHeader (AUTHORIZATION_HEADER , mCredentials .getHeaderAuth ());
131
132
}
132
133
@@ -149,7 +150,7 @@ private int saveExecuteHttpMethod(HttpBaseMethod method) throws Exception {
149
150
}
150
151
*/
151
152
152
- } while (retry );
153
+ } while (retry && repeatCounter < MAX_RETRY_COUNT );
153
154
154
155
return status ;
155
156
}
@@ -166,6 +167,11 @@ private void stacklog(int status, HttpBaseMethod method) {
166
167
"\n Url: " + method .getHttpUrl () +
167
168
"\n Cookeis: " + getCookiesForBaseUri ().toString () +
168
169
"\n Credentials type: " + mCredentials .getClass ().toString () +
170
+ "\n token: " + mCredentials .getAuthToken () +
171
+
172
+ "\n Headers: ++++" +
173
+ "\n " + method .getRequest ().headers ().toString () +
174
+ "+++++++++++++" +
169
175
"\n trace: " + ExceptionUtils .getStackTrace (e ) +
170
176
"---------------------------" );
171
177
}
0 commit comments