Skip to content

Commit 7e1daf3

Browse files
committed
feat: update README.md to include custom debug interceptors and request/response observers for Android and iOS
1 parent 9c0f2ff commit 7e1daf3

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,81 @@ getCookies('domain')
190190
})
191191

192192
```
193+
194+
## Debug Interceptors & Request/Response Observers
195+
196+
This library now supports custom debug interceptors and request/response observers to help with debugging network requests in development builds. These features are only active in DEBUG builds for security reasons.
197+
198+
### Summary of Recent Enhancements
199+
200+
**Latest Updates (June 2025):**
201+
1. **Android Custom Debug Interceptor Support** - Added ability to inject custom OkHttp interceptors for debugging network traffic
202+
2. **Android Debug Interceptor Refactoring** - Improved code organization by extracting interceptor logic into a dedicated method
203+
3. **iOS Request/Response Observers** - Added observer methods to monitor network requests and responses on iOS for debugging purposes
204+
205+
### Android Debug Interceptor
206+
207+
Add custom debug interceptors to monitor and modify HTTP requests/responses in Android:
208+
209+
```java
210+
// In your Android application code (Java/Kotlin)
211+
import com.toyberman.Utils.OkHttpUtils;
212+
import okhttp3.Interceptor;
213+
import okhttp3.logging.HttpLoggingInterceptor;
214+
215+
// Example: Add a custom logging interceptor
216+
Interceptor customInterceptor = new HttpLoggingInterceptor()
217+
.setLevel(HttpLoggingInterceptor.Level.BODY);
218+
219+
// Add the interceptor (only works in DEBUG builds)
220+
OkHttpUtils.addInterceptorForDebug(customInterceptor);
221+
```
222+
223+
**Features:**
224+
- Only active in DEBUG builds for security
225+
- Supports any OkHttp interceptor
226+
- Useful for detailed request/response logging
227+
- Can be used for request modification during development
228+
229+
### iOS Request/Response Observers
230+
231+
Monitor network requests and responses on iOS using observer methods:
232+
233+
```objc
234+
// In your iOS application code (Objective-C)
235+
#import "RNSslPinning.h"
236+
237+
// Set request observer to monitor outgoing requests
238+
[RNSslPinning setRequestObserver:^(NSURLRequest *request) {
239+
NSLog(@"Request: %@ %@", request.HTTPMethod, request.URL);
240+
// Add your custom request monitoring logic here
241+
}];
242+
243+
// Set response observer to monitor responses with timing
244+
[RNSslPinning setResponseObserver:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSTimeInterval startTime) {
245+
NSTimeInterval duration = ([[NSDate date] timeIntervalSince1970] * 1000.0) - startTime;
246+
NSLog(@"Response: %ld for %@ (%.2fms)", (long)response.statusCode, request.URL, duration);
247+
// Add your custom response monitoring logic here
248+
}];
249+
```
250+
251+
**Features:**
252+
- Only active in DEBUG builds for security
253+
- Monitor all outgoing requests
254+
- Track response data, status codes, and timing
255+
- Handle both successful responses and error cases
256+
- Captures original request details for correlation
257+
258+
### Use Cases
259+
260+
- **Network Debugging**: Monitor request/response flow during development
261+
- **Performance Analysis**: Track request timing and response sizes
262+
- **SSL/TLS Troubleshooting**: Debug certificate pinning issues
263+
- **API Development**: Verify request formats and response handling
264+
- **Integration Testing**: Monitor network calls during automated tests
265+
266+
**Note**: These debugging features are automatically disabled in production builds for security and performance reasons.
267+
193268
## Multipart request (FormData)
194269
195270
```javascript

0 commit comments

Comments
 (0)