Skip to content

Commit

Permalink
Merge branch 'develop' into release/v6.1.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/publish.yml
#	chopper/lib/src/interceptor.dart
#	chopper/lib/src/request.dart
#	chopper/pubspec.yaml
#	chopper/test/interceptors_test.dart
#	chopper_built_value/pubspec.yaml
#	example/lib/json_decode_service.vm.g.dart
#	example/lib/json_decode_service.worker.g.dart
#	example/pubspec.yaml
  • Loading branch information
techouse committed May 28, 2023
2 parents 636dbc3 + d824ded commit f4f9946
Showing 11 changed files with 281 additions and 12 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ jobs:
- id: checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 2
- run: git checkout HEAD^
- name: Load base version
id: load_base_version
run: |
@@ -79,4 +80,9 @@ jobs:
- name: Skip publish
id: skip_publish
if: ${{ env.IS_VERSION_GREATER == 0 }}
run: echo "Skipping publish for ${{ matrix.package }} because the version is not greater than the one on pub.dev"
run: echo "Skipping publish for ${{ matrix.package }} because the version is not greater than the one on pub.dev"
- name: Cleanup
id: cleanup
if: ${{ always() }}
run: |
rm -rf "$XDG_CONFIG_HOME/dart/pub-credentials.json"
10 changes: 10 additions & 0 deletions chopper/lib/src/interceptor.dart
Original file line number Diff line number Diff line change
@@ -151,6 +151,16 @@ class CurlInterceptor implements RequestInterceptor {
curl += ' -d \'$body\'';
}
}
if (baseRequest is http.MultipartRequest) {
final fields = baseRequest.fields;
final files = baseRequest.files;
fields.forEach((k, v) {
curl += ' -f \'$k: $v\'';
});
for (var file in files) {
curl += ' -f \'${file.field}: ${file.filename ?? ''}\'';
}
}
curl += ' "$url"';
chopperLogger.info(curl);

1 change: 1 addition & 0 deletions chopper/lib/src/request.dart
Original file line number Diff line number Diff line change
@@ -138,6 +138,7 @@ class Request extends http.BaseRequest with EquatableMixin {
@visibleForTesting
http.Request toHttpRequest() {
final http.Request request = http.Request(method, url)
..followRedirects = followRedirects
..headers.addAll(headers);

if (body != null) {
2 changes: 1 addition & 1 deletion chopper/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ environment:

dependencies:
equatable: ^2.0.5
http: ">=0.13.0 <1.0.0"
http: ">=0.13.0 <2.0.0"
logging: ^1.0.0
meta: ^1.3.0

29 changes: 29 additions & 0 deletions chopper/test/interceptors_test.dart
Original file line number Diff line number Diff line change
@@ -204,6 +204,35 @@ void main() {
),
);
});

final fakeRequestMultipart = Request(
'POST',
Uri.parse('/'),
Uri.parse('base'),
headers: {'foo': 'bar'},
parts: [
PartValue<int>('p1', 123),
PartValueFile<http.MultipartFile>(
'p2',
http.MultipartFile.fromBytes('file', [0], filename: 'filename'),
),
],
multipart: true,
);

test('Curl interceptors Multipart', () async {
final curl = CurlInterceptor();
var log = '';
chopperLogger.onRecord.listen((r) => log = r.message);
await curl.onRequest(fakeRequestMultipart);

expect(
log,
equals(
"curl -v -X POST -H 'foo: bar' -f 'p1: 123' -f 'file: filename' \"base/\"",
),
);
});
});
}

2 changes: 1 addition & 1 deletion chopper_built_value/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ dependencies:
built_value: ^8.0.0
built_collection: ^5.0.0
chopper: ^6.0.0
http: ^0.13.0
http: ">=0.13.0 <2.0.0"

dev_dependencies:
test: ^1.16.4
1 change: 1 addition & 0 deletions chopper_generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
@@ -457,6 +457,7 @@ class ChopperGenerator extends GeneratorForAnnotation<chopper.ChopperApi> {
_typeChecker(Map).isExactlyType(type) ||
_typeChecker(BuiltMap).isExactlyType(type)) return type;

// ignore: deprecated_member_use
if (generic.isDynamic) return null;

if (_typeChecker(List).isExactlyType(type) ||
6 changes: 5 additions & 1 deletion example/build.yaml
Original file line number Diff line number Diff line change
@@ -13,4 +13,8 @@ targets:
any_map: false
checked: false
explicit_to_json: true
create_to_json: true
create_to_json: true
squadron_builder:worker_builder:
options:
with_finalizers: true
serialization_type: List
2 changes: 1 addition & 1 deletion example/lib/json_decode_service.vm.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

226 changes: 222 additions & 4 deletions example/lib/json_decode_service.worker.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ dependencies:
analyzer:
http:
built_collection:
squadron: ^4.3.8
squadron: ^5.0.0

dev_dependencies:
build_runner:
@@ -23,7 +23,7 @@ dev_dependencies:
built_value_generator:
dart_code_metrics: '>=4.8.1 <6.0.0'
lints: ^2.0.0
squadron_builder: ^2.0.0
squadron_builder: ^2.1.2

dependency_overrides:
chopper:

0 comments on commit f4f9946

Please sign in to comment.