mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +00:00 
			
		
		
		
	Fix crash when response body is empty and solve issue when retrieving auth methods
This commit is contained in:
		
							parent
							
								
									64bfd6a7f7
								
							
						
					
					
						commit
						f20d2554bf
					
				| @ -78,14 +78,18 @@ public abstract class DavMethod extends HttpBaseMethod { | |||||||
|                         .build(); |                         .build(); | ||||||
| 
 | 
 | ||||||
|             } else if (mResponse != null) { |             } else if (mResponse != null) { | ||||||
|                 ResponseBody responseBody = ResponseBody.create( |                 // The check below should be included in okhttp library, method ResponseBody.create( | ||||||
|                         mResponse.body().contentType(), |                 // TODO check most recent versions of okhttp to see if this is already fixed and try to update if so | ||||||
|                         httpException.getResponseBody() |                 if (mResponse.body().contentType() != null) { | ||||||
|                 ); |                     ResponseBody responseBody = ResponseBody.create( | ||||||
|  |                             mResponse.body().contentType(), | ||||||
|  |                             httpException.getResponseBody() | ||||||
|  |                     ); | ||||||
| 
 | 
 | ||||||
|                 mResponse = mResponse.newBuilder() |                     mResponse = mResponse.newBuilder() | ||||||
|                         .body(responseBody) |                             .body(responseBody) | ||||||
|                         .build(); |                             .build(); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             return httpException.getCode(); |             return httpException.getCode(); | ||||||
|  | |||||||
| @ -66,7 +66,7 @@ public class RemoteOperationResult<T> | |||||||
|     private Exception mException = null; |     private Exception mException = null; | ||||||
|     private ResultCode mCode = ResultCode.UNKNOWN_ERROR; |     private ResultCode mCode = ResultCode.UNKNOWN_ERROR; | ||||||
|     private String mRedirectedLocation; |     private String mRedirectedLocation; | ||||||
|     private String mAuthenticate; |     private List<String> mAuthenticate = new ArrayList<>(); | ||||||
|     private String mLastPermanentLocation = null; |     private String mLastPermanentLocation = null; | ||||||
|     private T mData = null; |     private T mData = null; | ||||||
| 
 | 
 | ||||||
| @ -253,7 +253,9 @@ public class RemoteOperationResult<T> | |||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 if ("www-authenticate".equals(header.getKey().toLowerCase())) { |                 if ("www-authenticate".equals(header.getKey().toLowerCase())) { | ||||||
|                     mAuthenticate = header.getValue().get(0).toLowerCase(); |                     for (String value: header.getValue()) { | ||||||
|  |                         mAuthenticate.add(value.toLowerCase()); | ||||||
|  |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @ -494,7 +496,7 @@ public class RemoteOperationResult<T> | |||||||
|         return (mRedirectedLocation != null && !(mRedirectedLocation.toLowerCase().startsWith("https://"))); |         return (mRedirectedLocation != null && !(mRedirectedLocation.toLowerCase().startsWith("https://"))); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public String getAuthenticateHeaders() { |     public List<String> getAuthenticateHeaders() { | ||||||
|         return mAuthenticate; |         return mAuthenticate; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user