File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change
1
+ ## 1.3.3-wip
2
+
3
+ * Throw ` ClientException ` if ` CronetClient.send ` runs out of Java heap while
4
+ allocating memory for the request body.
5
+
1
6
## 1.3.2
2
7
3
8
* Upgrade ` package:jni ` to 0.10.1 and ` package:jnigen ` to 0.10.0 to fix method
Original file line number Diff line number Diff line change @@ -392,8 +392,22 @@ class CronetClient extends BaseClient {
392
392
headers.forEach ((k, v) => builder.addHeader (k.toJString (), v.toJString ()));
393
393
394
394
if (body.isNotEmpty) {
395
+ final JByteBuffer data;
396
+ try {
397
+ data = body.toJByteBuffer ();
398
+ } on JniException catch (e) {
399
+ // There are no unit tests for this code. You can verify this behavior
400
+ // manually by incrementally increasing the amount of body data in
401
+ // `CronetClient.post` until you get this exception.
402
+ if (e.message.contains ('java.lang.OutOfMemoryError:' )) {
403
+ throw ClientException (
404
+ 'Not enough memory for request body: ${e .message }' , request.url);
405
+ }
406
+ rethrow ;
407
+ }
408
+
395
409
builder.setUploadDataProvider (
396
- jb.UploadDataProviders .create2 (body. toJByteBuffer () ), _executor);
410
+ jb.UploadDataProviders .create2 (data ), _executor);
397
411
}
398
412
builder.build ().start ();
399
413
return responseCompleter.future;
Original file line number Diff line number Diff line change 1
1
name : cronet_http
2
- version : 1.3.2
2
+ version : 1.3.3-wip
3
3
description : >-
4
4
An Android Flutter plugin that provides access to the Cronet HTTP client.
5
5
repository : https://github.com/dart-lang/http/tree/master/pkgs/cronet_http
You can’t perform that action at this time.
0 commit comments