mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Fix null error in http interceptors
This commit is contained in:
		
							parent
							
								
									c05a11a7b4
								
							
						
					
					
						commit
						c50e199b76
					
				| @ -156,11 +156,14 @@ public class HttpClient { | ||||
|      * @param headerValue | ||||
|      */ | ||||
|     public static void addHeaderForAllRequests(String headerName, String headerValue) { | ||||
|         getOkHttpInterceptor() | ||||
|                 .addRequestInterceptor( | ||||
|         HttpInterceptor httpInterceptor = getOkHttpInterceptor(); | ||||
| 
 | ||||
|         if(getOkHttpInterceptor() != null) { | ||||
|             httpInterceptor.addRequestInterceptor( | ||||
|                     new RequestHeaderInterceptor(headerName, headerValue) | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static void deleteHeaderForAllRequests(String headerName) { | ||||
|         getOkHttpInterceptor().deleteRequestHeaderInterceptor(headerName); | ||||
|  | ||||
| @ -46,14 +46,20 @@ public class HttpInterceptor implements Interceptor { | ||||
|     public Response intercept(Chain chain) throws IOException { | ||||
|         Request request = chain.request(); | ||||
| 
 | ||||
|         for (RequestInterceptor interceptor : mRequestInterceptors) { | ||||
|             request = interceptor.intercept(request); | ||||
|         ListIterator<RequestInterceptor> requestInterceptorIterator = mRequestInterceptors.listIterator(); | ||||
| 
 | ||||
|         while (requestInterceptorIterator.hasNext()) { | ||||
|             RequestInterceptor currentRequestInterceptor = requestInterceptorIterator.next(); | ||||
|             request = currentRequestInterceptor.intercept(request); | ||||
|         } | ||||
| 
 | ||||
|         Response response = chain.proceed(request); | ||||
| 
 | ||||
|         for (ResponseInterceptor interceptor : mResponseInterceptors) { | ||||
|             response = interceptor.intercept(response); | ||||
|         ListIterator<ResponseInterceptor> responseInterceptorIterator = mResponseInterceptors.listIterator(); | ||||
| 
 | ||||
|         while (responseInterceptorIterator.hasNext()) { | ||||
|             ResponseInterceptor currentResponseInterceptor = responseInterceptorIterator.next(); | ||||
|             response = currentResponseInterceptor.intercept(response); | ||||
|         } | ||||
| 
 | ||||
|         return response; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user