Skip to content

Commit 844a0c1

Browse files
Copilotfarfromrefug
andcommitted
Revert iOS to Android-like response behavior - remove downloadFilePath streaming
Agent-Logs-Url: https://github.com/nativescript-community/https/sessions/8051dbe0-1e71-4045-88d9-5e25d50ae83e Co-authored-by: farfromrefug <655344+farfromrefug@users.noreply.github.com>
1 parent 9d81a53 commit 844a0c1

File tree

8 files changed

+255
-742
lines changed

8 files changed

+255
-742
lines changed

docs/ALAMOFIRE_MIGRATION.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -120,52 +120,53 @@ All features from the AFNetworking implementation have been preserved and enhanc
120120
- JSON deserialization
121121
- Raw data responses
122122
- Image conversion (UIImage)
123-
- File saving
124-
- **NEW: Streaming downloads** for memory-efficient large file handling
123+
- File saving via `.toFile()` method
125124
- Error handling with status codes
126125

127-
## New Features
126+
**Behavior:** Response data is loaded into memory as NSData (matching Android OkHttp). Users inspect status code and headers, then decide to call `.toFile()`, `.toArrayBuffer()`, etc.
128127

129-
### Streaming Downloads
130-
The new `downloadFilePath` option enables memory-efficient downloads by streaming directly to disk:
128+
## API Improvements
129+
130+
### Cleaner API Methods
131+
All Swift wrapper methods now use simplified, more intuitive names:
132+
- `request()` instead of `dataTaskWithHTTPMethod...`
133+
- `uploadMultipart()` instead of `POSTParametersHeaders...`
134+
- `uploadFile()` instead of `uploadTaskWithRequestFromFile...`
135+
- `uploadData()` instead of `uploadTaskWithRequestFromData...`
136+
137+
### Consistent Cross-Platform Behavior
138+
iOS now matches Android's response handling:
131139

132140
```typescript
133141
import { request } from '@nativescript-community/https';
134142

135-
// Option 1: Use downloadFilePath in request options
136-
const response = await request({
137-
method: 'GET',
138-
url: 'https://example.com/large-file.zip',
139-
downloadFilePath: '/path/to/save/file.zip',
140-
onProgress: (current, total) => {
141-
console.log(`Downloaded ${current} of ${total} bytes`);
142-
}
143-
});
144-
145-
// Option 2: Traditional toFile() still works but loads into memory first
143+
// Request completes and returns with status/headers/data
146144
const response = await request({
147145
method: 'GET',
148146
url: 'https://example.com/file.zip'
149147
});
148+
149+
// Inspect response first
150+
console.log('Status:', response.statusCode);
151+
console.log('Headers:', response.headers);
152+
153+
// Then decide what to do with the data
150154
const file = await response.content.toFile('/path/to/save/file.zip');
155+
// OR
156+
const buffer = await response.content.toArrayBuffer();
157+
// OR
158+
const json = response.content.toJSON();
151159
```
152160

153-
**Benefits of streaming downloads:**
154-
- No memory overhead for large files
155-
- Better performance on memory-constrained devices
156-
- Progress tracking during download
157-
- Automatic file path creation
158-
159-
### Cleaner API Methods
160-
All Swift wrapper methods now use simplified, more intuitive names:
161-
- `request()` instead of `dataTaskWithHTTPMethod...`
162-
- `uploadMultipart()` instead of `POSTParametersHeaders...`
163-
- `uploadFile()` instead of `uploadTaskWithRequestFromFile...`
164-
- `uploadData()` instead of `uploadTaskWithRequestFromData...`
161+
**Benefits:**
162+
- Same behavior on iOS and Android
163+
- Inspect status/headers before processing data
164+
- Flexible response handling
165+
- Simple, predictable API
165166

166167
## API Compatibility
167168

168-
The TypeScript API remains **100% compatible** with the previous AFNetworking implementation. No changes are required in application code that uses this plugin. New features are opt-in through additional options.
169+
The TypeScript API remains **100% compatible** with the previous AFNetworking implementation. No changes are required in application code that uses this plugin.
169170

170171
## Testing Recommendations
171172

docs/API_IMPROVEMENTS_SUMMARY.md

Lines changed: 0 additions & 277 deletions
This file was deleted.

0 commit comments

Comments
 (0)